💻 Computer Science · Algorithms

Algorithm tricks that make Big-O click

Sorting, searching, complexity, and Big-O notation — mastered.

🔄 Algorithms

Memory tricks

Proven mnemonics — fast to learn, hard to forget.

🎥 How Flashcards Work
A quick walkthrough of tap-to-flip, rating, and how card colors track what you're struggling with.
← Back Next →
Algorithms deck1 of 12
Tap to flip
← →
How well do YOU think you know this?
Easy Medium Hard Harder
Tap to flip back
Algorithms deck
Easy0
Medium0
Hard0
Harder0
Binary Search
Binary search: sorted array, cut in half each time → O(log n)
Binary Search
How binary search works and why it's dramatically faster than linear search
Start in the middle. Is target higher or lower? Eliminate half. Repeat. 1 million items → max 20 comparisons. Requires sorted data.
📖 Full Lesson →
🎥 Watch Instead
Alex walks through binary search step by step — 2:38.
Flashcard
🃏 Binary Search
Binary search — the requirement and the complexity?
Tap to flip
🃏 Answer
Binary search: sorted array, cut in half each time → O(log n)
Binary Search — Start in the middle. Is target higher or lower? Eliminate half. Repeat. 1 million items → max 20 comparisons. Requires sorted data.
Tap to flip back
Big-O Complexity Hierarchy
Big-O order: O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ)
Big-O Complexity Hierarchy
From fastest to slowest — know this order cold
O(1): constant, always same speed. O(log n): binary search. O(n): one scan. O(n log n): merge sort. O(n²): nested loops. O(2ⁿ): brute force combinations. Choose lowest complexity when possible.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Big-O Complexity Hierarchy
Big-O — the common complexities, fastest to slowest?
Tap to flip
🃏 Answer
Big-O order: O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ)
Big-O Complexity Hierarchy — O(1): constant, always same speed. O(log n): binary search. O(n): one scan. O(n log n): merge sort. O(n²): nested loops. O(2ⁿ): brute force combinations. Choose lowest complexity when possible.
Tap to flip back
Sorting Algorithms
Bubble O(n²), Merge O(n log n) always, Quick O(n log n) average
Sorting Algorithms
Three essential sorting algorithms and their complexities
Bubble sort: compare adjacent pairs, swap — simple but slow. Merge sort: divide and conquer, always O(n log n), stable. Quick sort: partition around pivot, O(n log n) average but O(n²) worst case.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Sorting Algorithms
Bubble vs merge vs quick sort — time complexity?
Tap to flip
🃏 Answer
Bubble O(n²), Merge O(n log n) always, Quick O(n log n) average
Sorting Algorithms — Bubble sort: compare adjacent pairs, swap — simple but slow. Merge sort: divide and conquer, always O(n log n), stable. Quick sort: partition around pivot, O(n log n) average but O(n²) worst case.
Tap to flip back
Algorithm Paradigms
Greedy: local best choice. Dynamic Programming: cache overlapping subproblems.
Algorithm Paradigms
Two major approaches to optimization problems
Greedy: always pick locally optimal — works for some problems (Dijkstra's, Huffman coding). Dynamic programming: break into overlapping subproblems, cache results — works for more complex problems (knapsack, Fibonacci).
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Algorithm Paradigms
Greedy vs dynamic programming — how do they differ?
Tap to flip
🃏 Answer
Greedy: local best choice. Dynamic Programming: cache overlapping subproblems.
Algorithm Paradigms — Greedy: always pick locally optimal — works for some problems (Dijkstra's, Huffman coding). Dynamic programming: break into overlapping subproblems, cache results — works for more complex problems (knapsack, Fibonacci).
Tap to flip back
Two-Pointer Technique
Two-pointer technique: O(n) solution for sorted array problems — move inward from both ends
Two-Pointer Technique
A powerful O(n) strategy for many array and string problems
Place one pointer at start, one at end. Move inward based on condition. Finds pairs that sum to target in O(n) instead of O(n²). Also used for: removing duplicates, palindrome check, container with most water.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Two-Pointer Technique
Two-pointer technique — when and how?
Tap to flip
🃏 Answer
Two-pointer technique: O(n) solution for sorted array problems — move inward from both ends
Two-Pointer Technique — Place one pointer at start, one at end. Move inward based on condition. Finds pairs that sum to target in O(n) instead of O(n²). Also used for: removing duplicates, palindrome check, container with most water.
Tap to flip back
Divide and Conquer
Divide and conquer: split problem in half, solve each half, combine. Merge sort, binary search, FFT.
Divide and Conquer
Breaking problems into smaller subproblems recursively
Three steps: Divide (split into subproblems), Conquer (solve recursively), Combine (merge solutions). Merge sort: split array in half, sort each half, merge → O(n log n). Binary search: split search space in half each time → O(log n). Master Theorem gives recurrence time complexity.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Divide and Conquer
Divide and conquer — the steps and examples?
Tap to flip
🃏 Answer
Divide and conquer: split problem in half, solve each half, combine. Merge sort, binary search, FFT.
Divide and Conquer — Three steps: Divide (split into subproblems), Conquer (solve recursively), Combine (merge solutions). Merge sort: split array in half, sort each half, merge → O(n log n). Binary search: split search space in half each time → O(log n). Master Theorem gives recurrence time complexity.
Tap to flip back
Shortest Path Algorithms
BFS (Breadth-First Search): shortest path in unweighted graph, uses queue. Dijkstra: shortest path with weights, uses priority queue.
Shortest Path Algorithms
Finding the fastest route through a graph
BFS (Breadth-First Search): finds shortest path in unweighted graphs — explores level by level. Dijkstra's algorithm: shortest path in weighted graphs with non-negative weights — uses a min-priority queue, greedy approach. Bellman-Ford: handles negative weights, detects negative cycles — O(VE).
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Shortest Path Algorithms
BFS vs Dijkstra for shortest paths?
Tap to flip
🃏 Answer
BFS (Breadth-First Search): shortest path in unweighted graph, uses queue. Dijkstra: shortest path with weights, uses priority queue.
Shortest Path Algorithms — BFS (Breadth-First Search): finds shortest path in unweighted graphs — explores level by level. Dijkstra's algorithm: shortest path in weighted graphs with non-negative weights — uses a min-priority queue, greedy approach. Bellman-Ford: handles negative weights, detects negative cycles — O(VE).
Tap to flip back
Memoization
Space-time tradeoff: memoization stores results to avoid recomputation — uses more memory, saves time
Memoization
Caching function results to avoid redundant computation
Memoization: store results of expensive function calls, return cached result when same inputs occur again. Top-down dynamic programming. Fibonacci: naive recursive = O(2ⁿ), memoized = O(n). Trade: O(n) extra space for O(n) time instead of O(2ⁿ). Key insight: avoid recomputing overlapping subproblems.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Memoization
Space-time tradeoff — how does memoization work?
Tap to flip
🃏 Answer
Space-time tradeoff: memoization stores results to avoid recomputation — uses more memory, saves time
Memoization — Memoization: store results of expensive function calls, return cached result when same inputs occur again. Top-down dynamic programming. Fibonacci: naive recursive = O(2ⁿ), memoized = O(n). Trade: O(n) extra space for O(n) time instead of O(2ⁿ). Key insight: avoid recomputing overlapping subproblems.
Tap to flip back
Sliding Window Technique
Sliding window: maintain a window of elements, slide it across array — O(n) instead of O(n²)
Sliding Window Technique
Efficiently solving subarray/substring problems
Fixed window: maintain window of size k, add one element, remove one element each step. Variable window: expand/contract window based on condition. Problems: maximum sum subarray of size k, longest substring without repeating characters. Avoids nested loops — O(n) instead of O(n²).
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Sliding Window Technique
Sliding window — how does it work, and why is it faster?
Tap to flip
🃏 Answer
Sliding window: maintain a window of elements, slide it across array — O(n) instead of O(n²)
Sliding Window Technique — Fixed window: maintain window of size k, add one element, remove one element each step. Variable window: expand/contract window based on condition. Problems: maximum sum subarray of size k, longest substring without repeating characters. Avoids nested loops — O(n) instead of O(n²).
Tap to flip back
Recursion vs Iteration
Recursion vs iteration: recursion elegant but uses call stack. Deep recursion can cause stack overflow.
Recursion vs Iteration
When to recurse and when to loop
Recursion: elegant, mirrors mathematical definition, natural for tree/graph problems. Call stack has limited size — deep recursion → stack overflow. Tail recursion: recursive call is the last operation — some languages optimize this. Iteration: explicit stack management, more memory-efficient, sometimes harder to read.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Recursion vs Iteration
Recursion vs iteration — the tradeoff?
Tap to flip
🃏 Answer
Recursion vs iteration: recursion elegant but uses call stack. Deep recursion can cause stack overflow.
Recursion vs Iteration — Recursion: elegant, mirrors mathematical definition, natural for tree/graph problems. Call stack has limited size — deep recursion → stack overflow. Tail recursion: recursive call is the last operation — some languages optimize this. Iteration: explicit stack management, more memory-efficient, sometimes harder to read.
Tap to flip back
P vs NP
NP-hard (Non-deterministic Polynomial-time hard) problems: no known polynomial solution. Traveling salesman, knapsack, graph coloring.
P vs NP
The most important unsolved problem in computer science
P: problems solvable in polynomial time. NP: solutions verifiable in polynomial time. NP-complete: hardest problems in NP. P=NP?: if any NP-complete problem has a polynomial solution, all do. Most believe P≠NP. Practical: use approximation algorithms or heuristics for NP-hard problems.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 P vs NP
NP-hard problems — what are they, with examples?
Tap to flip
🃏 Answer
NP-hard (Non-deterministic Polynomial-time hard) problems: no known polynomial solution. Traveling salesman, knapsack, graph coloring.
P vs NP — P: problems solvable in polynomial time. NP: solutions verifiable in polynomial time. NP-complete: hardest problems in NP. P=NP?: if any NP-complete problem has a polynomial solution, all do. Most believe P≠NP. Practical: use approximation algorithms or heuristics for NP-hard problems.
Tap to flip back
Amortized Analysis
Amortized analysis: occasional expensive operations averaged over many cheap ones — ArrayList doubling
Amortized Analysis
Why some data structures are efficient despite occasional slow operations
ArrayList/dynamic array: usually O(1) append, occasionally O(n) when resizing (copies all elements to new array). But doubling strategy means O(n) happens rarely — amortized O(1) per append. Stack push/pop: amortized O(1). Amortized analysis considers the average cost over a sequence of operations.
📖 Full Lesson →
🎥 Watch Instead
▶
Video coming soon
This lesson's animated video hasn't been made yet — check back soon.
Flashcard
🃏 Amortized Analysis
Amortized analysis — what is it?
Tap to flip
🃏 Answer
Amortized analysis: occasional expensive operations averaged over many cheap ones — ArrayList doubling
Amortized Analysis — ArrayList/dynamic array: usually O(1) append, occasionally O(n) when resizing (copies all elements to new array). But doubling strategy means O(n) happens rarely — amortized O(1) per append. Stack push/pop: amortized O(1). Amortized analysis considers the average cost over a sequence of operations.
Tap to flip back
🎓 Common Exam Questions

No saved cards yet — click ☆ Save on any memory trick.

Live group chat — up to 8 students per room