Question 21
EasyWhich of these complexities is polynomial?
- A.
O(3ⁿ)
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
Which of these complexities is polynomial?
O(3ⁿ)
O(2ⁿ)
O(n³)
O(n!)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of checking every subset of n items?
O(n log n)
O(2ⁿ)
O(n²)
O(n)
Sign up free to see the answer and a step-by-step explanation.
What is meant by the worst-case time complexity of an algorithm?
The time on the smallest input
The average over random inputs
The time on a slow computer
The maximum time it takes over all inputs of size n
Sign up free to see the answer and a step-by-step explanation.
Two loops run one after the other (not nested), each n times. What is the total time complexity?
O(n²)
O(2ⁿ)
O(log n)
O(n)
Sign up free to see the answer and a step-by-step explanation.
For large n, which is faster: an O(n log n) algorithm or an O(n²) algorithm?
It depends only on the language
O(n²)
They are always equal
O(n log n)
Sign up free to see the answer and a step-by-step explanation.
What is the output of this code?
count = 0
for i in range(4):
for j in range(i):
count += 1
print(count)
16
6
Sign up free to see the answer and a step-by-step explanation.
What is the worst-case time complexity of standard QuickSort algorithm when selecting the last element as the pivot?
O(N log N)
O(N)
O(N^2)
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 = 1
while i < n:
i *= 2
O(n log n)
O(n)
O(log n)
O(√n)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of this code?
for i in range(n):
for j in range(i):
count += 1
O(n)
O(n log n)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of this code?
for i in range(n):
j = 1
while j < n:
j *= 2
O(n)
O(log² n)
Sign up free to see the answer and a step-by-step explanation.
10
4
O(n²)
O(n³)
O(n²)
O(n log n)