Beginner DSA practice path
Start with a single array lookup and finish by counting the ways up a staircase. Work through each stage in order. Predict the next move in the lab, then try the paired exercise. Each stage ends with a challenge where you choose an approach, explain why it fits, and predict a result.
Stage 1 · Lookups and running time
What do you know at the start of a lookup? Try an index, a value to search for, a link and a key.
- Array indexes lab
Read a card by its index. In the exercise, track which name moves to index zero after a rotation.
Practice · Right Rotation - Linear search lab
Scan one item at a time. To find the largest reading, keep the best value seen so far.
Practice · Largest Array Element - Big O and counting comparisons lab
Count the work in one pass. Then count the multiplications needed to calculate a factorial as the input grows.
Practice · Factorial - Linked lists lab
Walk from the head. After each insertion, redraw the links and walk the list again.
Practice · Build a singly linked list - Hash tables lab
Use a key to pick a starting bucket. In the exercise, follow the probe to the next free slot.
Practice · Hash table
Count birds at a feeder
A volunteer enters a species name for each sighting. The same name can appear many times. You need to look up each species by name and show its total after every entry, without rereading earlier entries. What would you keep?
Take the challenge
Stage 2 · Strings and two pointers
Count repeated characters, walk inward from both ends of a string, and combine two sorted lists.
- Character frequency lab
Update a tally each time a character appears. Use the final counts to describe the whole string.
Practice · Counting a Character - Reversing with two pointers lab
Compare characters at opposite ends. Apply the same pair of moving indexes to reverse a string.
Practice · String Reversal - Merging sorted arrays lab
Compare the first unused item in each sorted list. Move one item at a time into the result.
Practice · Merging Sorted Arrays
Merge two race results
Two finish-line cameras each produce a list of times, earliest first. You need one results list in time order. Which approach can read each time just once?
Take the challenge
Stage 3 · Sorting, heaps and search
Put values in order, then use one comparison to rule out a whole range or branch.
- Bubble sort lab
Watch the largest card move right during a bubble-sort pass. Then build a sorted row by merging two sorted pieces.
Practice · Mergesort - Min-heap insertion lab
Track the smallest item at the root. Trace how the heap restores its order when the collection changes.
Practice · Min-heap insertion - Binary search lab
Point to the middle of the sorted row. Count one check each time you compare the target with a middle value.
Practice · Binary search - Binary search trees lab
Follow the target left or right. Carry the allowed range down each branch to spot a misplaced value.
Practice · Validate a binary search tree
Find a frame in a recording
A camera stored a million frames in an array with strictly increasing timestamps. You can open any position, but each frame takes time to load. You want to find a given timestamp or report it missing. Which search would keep even an unsuccessful lookup fast?
Take the challenge
Stage 4 · Stacks and recursion
An editor remembers which change to undo. A recursive function remembers which call to resume. Trace the most recent unfinished item in each.
- Stacks lab
Write each edit above the previous one. Cross out the top edit each time the editor undoes a change.
Practice · Stack - Recursion lab
Pause at the base case and trace the returns. In Hanoi, work out when the smaller disks have cleared the largest disk.
Practice · Solve the Tower of Hanoi
Resume a recipe
A recipe can send you to another recipe to make an ingredient. That recipe can send you to a third. Each time you switch, you note the recipe and the step where you paused. How should you keep those notes so you can resume the right step?
Take the challenge
Stage 5 · Queues and graph traversal
Follow one branch of a graph in depth. Then use a queue to find a route with the fewest stops.
- Queues lab
Write the waiting print jobs from front to back. Keep the jobs already waiting in place when a new one arrives.
Practice · Queue - Depth-first search lab
Follow an unvisited neighbor until the branch ends. Return to the last fork to explore the next branch.
Practice · Depth-first search on a graph - Graph traversal lab
Queue each newly discovered station. In the trail exercise, group the landmarks by how many hops it takes to reach them.
Practice · Shortest paths with BFS
From print jobs to bus stops
A map and a poster are waiting to print. While the map prints, a flyer arrives. The poster stays ahead of the flyer. That rule is first in, first out (FIFO).
Breadth-first search (BFS) queues stops the same way. Take a stop from the front, mark each unseen neighbor as seen and add it at the back. Each connection counts as one hop. Stops waiting at the current distance get their turn before the next layer, so the first time you discover a destination you have reached it in the fewest hops.
Catch the bus to Museum
These are the only two lines. Both run in both directions. Each ride between consecutive stops is one hop.
- From Depot, the Mill line calls at Mill, Lake, Arena and Museum in order.
- From Depot, the Pier line calls at Pier, Hill and Museum in order.
Start at Depot. Queue Mill first and Pier second. You take Mill from the front and add Lake at the back.
Solve a word ladder
Turn CAT into DOG by changing one letter per move. Each new word must be on the puzzle’s word list, and each change costs one move. Which search guarantees the fewest moves if a solution exists?
Take the challenge
Stage 6 · Backtracking and dynamic programming
Build every possible selection, then see how saving a smaller answer can avoid repeated work.
- Backtracking with subsets lab
Choose an item, explore that choice, then undo it to try another selection.
Practice · Generate subsets - Dynamic programming with Fibonacci lab
Build each Fibonacci number from two earlier answers. Track exactly which values the next step needs.
Practice · Fibonacci sequence
Count ways up the stairs
A robot climbs one or two steps per move. You need the number of ways to reach a landing. Many routes pass through the same step. How can you reuse that work?