โ† Computer Science Fundamentals learning path
Computer Science Fundamentals ยท Module 3 of 10

Algorithms and Big-O

An algorithm is a step-by-step method; Big-O describes how its cost grows.

๐Ÿ“– Key ideas

  1. Algorithms take input and produce output in a finite number of steps.
  2. Big-O describes growth: O(1), O(log n), O(n), O(n log n), O(nยฒ).
  3. Linear search is O(n); binary search on sorted data is O(log n).
  4. Nested loops over the same data are often O(nยฒ).
  5. Space complexity measures extra memory used.
๐Ÿ’ก Real-life example: Like finding a word in a dictionary: flipping page by page is O(n), opening in the middle and halving is O(log n).
AlgorithmStep-by-step method to solve a problem
Big-OHow cost grows with input size
O(log n)Grows slowly by halving
Space complexityExtra memory an algorithm needs