Logarithms
What logarithms are, key properties, common vs natural log, and why O(log n) appears everywhere in CS. The inverse of exponentiation.
Lessons
1. Intro
The Goal
2. What Are Logarithms? (The inverse)
Undoing exponentiation
3. Logarithm Notation (Reading the symbols)
Base and argument explained
4. Quiz: Basic Logarithms (Knowledge check)
Test your understanding
5. Binary Logarithm (Base 2)
Most common in CS
6. Common Logarithm (Base 10)
Scientific notation base
7. Natural Logarithm (Base e)
Calculus and growth rates
8. Logarithm of 1 (Special case)
Any base equals zero
9. Logarithm of the Base (Another special case)
Always equals one
10. Product Rule (Multiplication becomes addition)
First logarithm property
11. Quotient Rule (Division becomes subtraction)
Second logarithm property
12. Power Rule (Exponent comes out front)
Third logarithm property
13. Quiz: Logarithm Properties (Knowledge check)
Test your understanding
14. Change of Base Formula (Converting bases)
Switch between any bases
15. Why Bases Don't Matter in Big-O (Constant factor)
All logarithms are equivalent
16. The Halving Pattern (Where log n comes from)
Divide and conquer
17. Binary Search Example (Classic log n algorithm)
Halving the search space
18. Tree Height Example (Another log n pattern)
Balanced binary trees
19. Quiz: Logarithmic Growth (Knowledge check)
Test your understanding
20. Problem - Power Function (Entry problem)
LeetCode 50
21. Power - The Insight (Squaring trick)
Halve the exponent
22. Power - Implementation (The code)
Recursive solution
23. Power - Complexity Analysis (Why it's logarithmic)
Time and space breakdown
24. Lessons from Power (Summary)
What you learned
25. Problem - Search Insert Position (Second problem)
LeetCode 35
26. Search Insert - The Insight (Binary search variant)
Find or insert position
27. Search Insert - Implementation (The code)
Binary search solution
28. Search Insert - Walkthrough (Tracing execution)
Step-by-step example
29. Lessons from Search Insert (Summary)
What you learned
30. Problem - Perfect Squares (Third problem)
LeetCode 279
31. Perfect Squares - The Insight (DP with square roots)
Building from smaller values
32. Perfect Squares - Implementation (The code)
DP solution
33. Perfect Squares - Logarithm Connection (Square roots and logs)
Why logs appear
34. Lessons from Perfect Squares (Summary)
What you learned
35. Logarithms in Merge Sort (Divide and conquer)
Tree height analysis
36. Logarithms in Quicksort (Average case)
Balanced partitions
37. Logarithms in Heaps (Insert and extract)
Heap operations
38. Quiz: Logarithms in Algorithms (Knowledge check)
Test your understanding
39. Problem - Find Kth Smallest (Fourth problem)
LeetCode 378
40. Kth Smallest - The Insight (Binary search on values)
Count elements below threshold
41. Kth Smallest - Implementation (The code)
Binary search solution
42. Lessons from Kth Smallest (Summary)
What you learned
43. Logarithms and Bit Manipulation (Powers of 2)
Binary representation
44. Logarithms and Number of Digits (Base 10)
Counting digits
45. Quiz: Logarithms and Numbers (Knowledge check)
Test your understanding
46. Logarithmic Growth vs Linear Growth (Scaling comparison)
Why log n is fast
47. Logarithmic Space Complexity (Recursion depth)
Call stack usage
48. Common Logarithm Mistakes (Pitfalls to avoid)
What to watch out for
49. Section Recap
What we learned