1.9
-
Order the following complexity bounds in increasing order:
A. \(O(n)\) B. \(O(\log n)\) C. \(O(n \cdot \log n)\) D. \(O(n^2)\) E. \(O(n^4)\) F. \(O(n!)\) G. \(O(2^n)\) H. \(O(n^n)\)
K. \(O(1)\)
KBACDEGFH
-
Calculate the time bound (in big \(O\) notation) of the next time functions:
A. \(T(n) = n(n + 1)\)---\(O(n^2)\) B. \(T(n) = \sum_{i=1}^n c\)---\(O(n)\) C. \(T(n)=n\cdot\left(n+\sum_{i=1}^{n}\sum_{i=1}^{n}\sum_{i=1}^{n}\sum_{i=1}^{n}c\right)\)---\(O(n^5)\) D. \(T(n) = n(n + 1) + n(n \cdot n) + n \cdot \frac{n}{2}\)---\(O(n^3)\) E. \(T(n) = \prod_{i=1}^n i\)---\(O(n!)\)
F. \(T(n)=\prod_{i=1}^{n}c\)---\(O(c^{n})\) G. \(T(n)=n\cdot\left(n\cdot\left(\log n+n\right)\right)\)---\(O(n^3)\)
-
Calculate the time function \(T(n)\) for the programming exercises present in the 10th and 11th tutorials and calculate their respective time bounds. You can improve the time efficiency of your solutions? How?
-
Define and implement a function:
int search(int seq[], int lower, int higher, int elem);
that search an element inside of a sequence.
This function must have a constant time complexity ifelem
is in the first or
last position ofseq