Big O notation, common sorting and searching algorithms, and recursion patterns tested in technical interviews and coursework.
38 cards · basic cards · AI-written, checked twice. Edit anything.
- What does Big O notation measure?
Show answer
How the runtime or space requirements of an algorithm grow as input size increases.
- Define O(1) time complexity.
Show answer
Constant time; the runtime does not change regardless of input size.
- Define O(n) time complexity.
Show answer
Linear time; runtime grows proportionally with input size n.
- Define O(log n) time complexity.
Show answer
Logarithmic time; runtime grows with the logarithm of input size.
- Define O(n^2) time complexity.
Show answer
Quadratic time; runtime grows with the square of input size.
- Define O(n log n) time complexity.
Show answer
Linearithmic time; runtime is n times the logarithm of n.
- Define O(2^n) time complexity.
Show answer
Exponential time; runtime doubles with each increase in input size.
- What is the time complexity of accessing an array element by index?
Show answer
O(1) constant time.
- What is the time complexity of searching an unsorted array for a value?
Show answer
O(n) linear time.
- What is the time complexity of binary search on a sorted array?
Show answer
O(log n) logarithmic time.
- What must be true about an array before binary search can be used?
Show answer
The array must be sorted.
- What is the time complexity of inserting an element at the beginning of an array?
Show answer
O(n) linear time.
- What is the time complexity of appending an element to a dynamic array with available capacity?
Show answer
O(1) amortized constant time.
- What is the average time complexity of searching a hash table?
Show answer
O(1) constant time with a good hash function.
- What is the time complexity of quicksort in the average case?
Show answer
O(n log n) linearithmic time.