Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
aa:lab:05 [2020/11/05 23:50] calin_andrei.bucur |
aa:lab:05 [2020/11/15 13:11] (current) fabianpatras |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Lab 05 - Asymptotic notations ====== | + | ====== Lab 06 - Asymptotic notations ====== |
| Line 12: | Line 12: | ||
| ==== 2. Properties of asymptotic notations ==== | ==== 2. Properties of asymptotic notations ==== | ||
| - | **2.1** Prove that if $math[lim] $math[g(n) \over f(n) = 0] implies that $math[g(n) \in o(f(n))], for n reaching infinity. Hint: use the "epsilon" or "Cauchy" limit definition for sequences. | + | **2.1** Prove that if $math[lim_{n\rightarrow \infty}] $math[g(n) \over f(n)] $math[= 0] implies that $math[g(n) \in o(f(n))], for n reaching infinity. Hint: use the "epsilon" or "Cauchy" limit definition for sequences. |
| **2.2** Prove that $math[f(n) \in Ω(log(n))] and $math[g(n) \in O(n)] implies $math[f(n) \in Ω(log(g(n)))]. | **2.2** Prove that $math[f(n) \in Ω(log(n))] and $math[g(n) \in O(n)] implies $math[f(n) \in Ω(log(g(n)))]. | ||
| Line 18: | Line 18: | ||
| **2.3** Prove that $math[f(n) \in Ω(g(n))] and $math[g(n) \in O(n ^ 2)], then $math[g(n) \over f(n)] $math[\in O(n)]. | **2.3** Prove that $math[f(n) \in Ω(g(n))] and $math[g(n) \in O(n ^ 2)], then $math[g(n) \over f(n)] $math[\in O(n)]. | ||
| - | **2.4** $math[O(n) \cap Ω(n) = Θ(n)] ? | + | **2.4** $math[O(n) \cap |
| + | Ω(n) = Θ(n)] ? | ||
| **2.5** $math[O(n) = Θ(n) \cup o(n)] ? | **2.5** $math[O(n) = Θ(n) \cup o(n)] ? | ||
| Line 30: | Line 31: | ||
| Plot the function |$math[sin(n)*n]|, using the command: ''plot abs(sin(x)*x)''. ''abs'' stands for absolute value. | Plot the function |$math[sin(n)*n]|, using the command: ''plot abs(sin(x)*x)''. ''abs'' stands for absolute value. | ||
| - | Use the command ''plot abs(sin(x)*x), 2*x'' to compare the two functions. | + | Use the command ''plot abs(sin(x)*x), x'' to compare the two functions. |
| **3.3** Write the following script file: | **3.3** Write the following script file: | ||
| Line 42: | Line 43: | ||
| f(x) = abs(sin(x)*x) | f(x) = abs(sin(x)*x) | ||
| - | g(x) = 2*x | + | g(x) = x |
| plot f(x),g(x) | plot f(x),g(x) | ||
| Line 86: | Line 87: | ||
| The output of the script should be a list of values: | The output of the script should be a list of values: | ||
| + | <code> | ||
| a b | a b | ||
| + | </code> | ||
| - | where a is the **size of the input**, expressed as a natural number and b is the running time for gcd. | + | where ''a'' is the **size of the input**, expressed as a natural number and ''b'' is the running time for gcd. |
| + | |||
| + | For instance, for x = 10000, ''b'' will be the running time of gcd, on the 10000th and 9999th fibonacci number. ''a'' will be the **size** of the input, i.e. the number of bits required to store the value $math[fibo(x) + fibo(x+1)], rounded to a natural number. | ||
| + | |||
| + | **3.9** Write a gnuplot script to plot the data collected from the python script, and compare it to the **linear** function. Comment the results. How does the execution time grow? Find the suitable function. | ||
| - | For instance, for x = 10000, b will be the running time of gcd, on the 10000th and 9999th fibonacci number. a will be the SIZE of the input, i.e. the number of bits required to store the value $math[fibo(x) + fibo(x+1)], rounded to a natural number | ||