Question 11
EasyWhat does space complexity measure?
- A.
How fast the CPU is
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What does space complexity measure?
How fast the CPU is
How the memory an algorithm needs grows with the input size
How much disk space the program file takes
The number of lines of code
Sign up free to see the answer and a step-by-step explanation.
Which of these grows the slowest as n increases?
O(n²)
O(n log n)
O(n)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of finding the largest value in an unsorted array of n elements?
O(n)
O(1)
O(log n)
O(n²)
Sign up free to see the answer and a step-by-step explanation.
What is the best-case time complexity of linear search?
O(n)
O(n²)
O(1)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
What does Big-Omega (Ω) notation describe?
The exact average time
A lower bound on an algorithm's growth
An upper bound
The memory used
Sign up free to see the answer and a step-by-step explanation.
What does Big-Theta (Θ) notation describe?
Only a lower bound
A tight bound: the growth is bounded above and below by the same function
The best case only
Only an upper bound
Sign up free to see the answer and a step-by-step explanation.
An O(n²) algorithm takes 1 second for n = 1,000. Roughly how long will it take for n = 2,000?
1 second
2 seconds
4 seconds
8 seconds
Sign up free to see the answer and a step-by-step explanation.
An O(n) algorithm takes 2 seconds for n = 1,000,000. Roughly how long will it take for n = 3,000,000?
6 seconds
2 seconds
18 seconds
9 seconds
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of this loop: for (i = 1; i < n; i = i * 2)?
O(n²)
O(n)
O(1)
O(log n)
Sign up free to see the answer and a step-by-step explanation.
Simplify O(n + log n).
O(n + 1)
O(n)
O(log n)
O(n log n)
Sign up free to see the answer and a step-by-step explanation.