Junior — Middle
Can you name the main categories of algorithm complexity?
sobes.tech AI
Answer from AI
The main categories of algorithm complexity are usually expressed in terms of asymptotic evaluation of execution time or memory usage. Here are the most common classes:
- O(1) — constant complexity: execution time does not depend on input size.
- O(log n) — logarithmic complexity: for example, binary search.
- O(n) — linear complexity: iterating over all elements.
- O(n log n) — linear-logarithmic: often found in efficient sorting algorithms (e.g., quicksort).
- O(n²) — quadratic: nested loops over the entire array.
- O(2^n) — exponential: for example, enumerating all subsets.
- O(n!) — factorial: enumerating all permutations.
These categories help evaluate how an algorithm scales as the volume of data increases.