Algorithms for Computer Sciences
Core algorithms are the well-known procedures for sorting, searching, graph traversal and optimisation, together with the design strategies behind them. Examples include merge sort, binary search, BFS, DFS, Dijkstra's shortest path, greedy choices and dynamic programming. Learning them gives you ready-made methods and a way of designing new ones.
Stage: Data Structures and Algorithms · Part of the Computer Science roadmap · Last reviewed 19 November 2026
What to learn in Algorithms
- Implement merge sort and quicksort and compare their worst-case behaviour
- Apply binary search to a sorted array and to an answer range
- Use BFS and DFS to explore a graph and find connected components
- Run Dijkstra's algorithm on a weighted graph with non-negative edges
- Decide whether a problem suits a greedy approach or dynamic programming
Algorithms interview questions
What is the difference between greedy algorithms and dynamic programming?
A greedy algorithm commits to the locally best choice at each step and never revisits it, which is correct only when the problem has the greedy-choice property. Dynamic programming solves all relevant subproblems and combines them, so it handles cases where local choices can mislead.
Why is quicksort often fast in practice despite O(n^2) worst case?
Its average cost is O(n log n), it sorts in place with good cache behaviour, and a random or median-of-three pivot makes the worst case very unlikely. Implementations also switch to simpler methods for small partitions, which cuts overhead further.
Where Algorithms fits in the Computer Science roadmap
Algorithms belongs to the Data Structures and Algorithms stage (beginner level). The toolkit.
Other units in this stage
Back to the full Computer Science roadmap