What is the worst case time complexity of the algorithm shown in the picture below:
MERGE(A, p,q,r)
n?=q-p+1
N?=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 n?
R[j] = A[q + j]
L[n? + 1] = ?
R[n? + 1] = ?
i = 1
j = 1
for k = p to r
if L[i] ? R[j]
A[k] = L[i]
i=i+1
else A[k] = R[j]
j = j + 1
Consider the following function:
f(n) = 2^n + 4 n + 9 n^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))
O(n), aka linear time
O(nlog(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(n^3)
O(n)
O(n^2)
O(nk), where k is the compatibility number.
O (log n)
O (n^2)
O (n)
O (n^3)
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.
log n +1
n. log n
log n
log n -1