What is the worst-case time complexity of the algorithm shown in the picture below: MERGE(A, p, q, r)?
Let n = q - p + 1 and n2 = r - q.
Let L[1..n+1] and R[1..n+1] be new arrays.
For i = 1 to n, L[i] = A[p + i - 1].
For j = 1 to n2, R[j] = A[q + j].
L[n+1] = R[n2+1] = 0.
Set i = 1 and j = 1.
For k = p to r,
if L[i] <= R[j],
then A[k] = L[i] and i = i + 1.
else,
A[k] = R[j] and j = j + 1.
Consider the following function: f(n) = 2^n + 4n + 9n^2.
Which of the following big-Oh notations most closely describes the big-Oh of this function?
O(1), aka constant time
O(log n), aka logarithmic time
O(n), aka linear time
O(n log n)
O(n^2), aka quadratic time
O(n^3), aka cubic time
O(2^n), aka exponential time
O(3^n), aka exponential time
Something else.
What is the time complexity of the naive matrix multiplication method?
O(nk), where k is the compatibility number.
If the number of leaf nodes in a binary tree is n, then what is the number of levels in the tree? Assume the root is at level 0.
O(log n + 1)
O(n log n)
O(log n)
O(log n - 1)