Software Engineer
easyexplain-big-o-notation

Explain Big O notation with examples.

Answer

Big O notation describes how an algorithm’s time or space grows as input size (n) grows. **Common time complexities:** - **O(1):** Constant time (array index lookup) - **O(log n):** Logarithmic (binary search) - **O(n):** Linear (single loop) - **O(n log n):** Efficient sorting (merge sort) - **O(n^2):** Nested loops (bubble sort) **Interview tip:** Always mention worst-case vs average-case, and include space complexity when relevant. Big O helps compare scalability before optimizing micro-details.

Related Topics

AlgorithmsPerformanceComputer Science