Step 3
Algorithms
Finding the best way to solve a problem and showing why it is the best. Sorting, searching, graph algorithms and dynamic programming live here.
Know these firstData StructuresDiscrete Mathematics
- Sorting
- Binary search
- Divide and conquer
- Greedy algorithms
- Dynamic programming
- BFS and DFS
- Shortest paths
Why it matters
If data structures answer "where do I keep the data", algorithms answer "what do I do with it". The shortest route in navigation, ranking in a search engine and AI in games are all topics of this course. Most technical interview questions come from here too.
What to know
- Sorting algorithms: insertion, merge, quick and heap sort, and how they compare.
- Binary search and searching sorted data.
- Divide and conquer; solving recurrences (the master theorem).
- Greedy algorithms and when they give the right answer.
- Dynamic programming: storing and reusing subproblem results.
- Graph algorithms: BFS, DFS, Dijkstra, minimum spanning trees.
- P, NP and the idea that some problems have no known fast solution.
Practice and projects
- Run every algorithm by hand on a small example on paper, then code it.
- Learn dynamic programming by solving problems; use topic tags on LeetCode and Codeforces.
- Time your own sorts on large inputs and check your Big-O estimate.
Common mistakes
- Memorizing solutions; they fail as soon as the interview question changes a little.
- Jumping to a DP table without first writing the recursive solution.
- Focusing only on speed without thinking about correctness.