Question 51
MediumIs n² = O(n³)? Is n³ = O(n²)?
- A.
Yes; yes
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
Is n² = O(n³)? Is n³ = O(n²)?
Yes; yes
Yes; no
No; no
No; yes
Sign up free to see the answer and a step-by-step explanation.
For n = 10⁶ and about 10⁸ simple operations per second, which complexity is too slow for a 1-second limit?
O(n²)
O(n log n)
O(n)
O(n √n) for small constants
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of the naive check 'is n prime?' that tests divisors from 2 to √n?
O(√n)
O(n)
O(1)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
Which describes the average-case time of quick sort with random pivots?
Θ(log n)
Θ(n²)
Θ(n)
Θ(n log n)
Sign up free to see the answer and a step-by-step explanation.
Using the Master Theorem, what does T(n) = 2T(n/2) + O(1) solve to?
O(1)
O(n log n)
O(log n)
O(n)
Sign up free to see the answer and a step-by-step explanation.
Using the Master Theorem, what does T(n) = T(n/2) + O(1) solve to?
O(1)
O(n)
O(n log n)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
What does T(n) = T(n − 1) + O(n) solve to?
O(n²)
O(n log n)
O(n)
O(2ⁿ)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of the naive recursive Fibonacci function fib(n) = fib(n − 1) + fib(n − 2)?
O(n)
O(2ⁿ) (more precisely about O(1.618ⁿ))
O(n²)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of this code?
i = n
while i > 0:
for j in range(i):
count += 1
i //= 2
O(log n)
O(n log n)
Sign up free to see the answer and a step-by-step explanation.
Which statement about Big-O, Big-Ω and Big-Θ is correct?
Ω is an upper bound
Θ applies only to the worst case
O is a tight bound
Θ is a tight bound: f is Θ(g) when it is both O(g) and Ω(g)
Sign up free to see the answer and a step-by-step explanation.
O(n)
O(n²)