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?
- How the runtime or space requirements of an algorithm grow as input size increases.
- Define O(1) time complexity.
- Constant time; the runtime does not change regardless of input size.
- Define O(n) time complexity.
- Linear time; runtime grows proportionally with input size n.
- Define O(log n) time complexity.
- Logarithmic time; runtime grows with the logarithm of input size.
- Define O(n^2) time complexity.
- Quadratic time; runtime grows with the square of input size.
- Define O(n log n) time complexity.
- Linearithmic time; runtime is n times the logarithm of n.
- Define O(2^n) time complexity.
- Exponential time; runtime doubles with each increase in input size.
- What is the time complexity of accessing an array element by index?
- O(1) constant time.
- What is the time complexity of searching an unsorted array for a value?
- O(n) linear time.
- What is the time complexity of binary search on a sorted array?
- O(log n) logarithmic time.
- What must be true about an array before binary search can be used?
- The array must be sorted.
- What is the time complexity of inserting an element at the beginning of an array?
- O(n) linear time.
- What is the time complexity of appending an element to a dynamic array with available capacity?
- O(1) amortized constant time.
- What is the average time complexity of searching a hash table?
- O(1) constant time with a good hash function.
- What is the time complexity of quicksort in the average case?
- O(n log n) linearithmic time.