advanced~6h
Sorting, Searching, and Graph Problem Set
A themed set of classic sorting, searching, and graph problems — a from-scratch divide-and-conquer sort, binary search and its off-by-one traps, binary search on a rotated array, BFS versus DFS graph traversal, and directed-cycle detection — closing out the coding practice bank with the algorithmic building blocks almost every harder interview question is assembled from.
Learning objectives
- Implement mergesort from scratch and explain its divide-and-conquer structure and tradeoffs against quicksort
- Implement binary search correctly, naming the specific off-by-one bugs that most commonly break it
- Adapt binary search to find a target in a rotated sorted array by identifying which half is properly sorted at each step
- Implement both BFS and DFS graph traversal and explain when each is the more natural choice
- Detect a cycle in a directed graph using DFS with a three-color (unvisited/in-progress/done) node-state scheme
- Explain why cycle detection in a directed graph needs the three-state scheme while an undirected graph only needs a simple visited set
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Core Java Mastery library.
Sorting, Searching, and Graph Problem Set