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.

  1. 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
  2. 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
  3. 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
  4. Linked lists lab

    Walk from the head. After each insertion, redraw the links and walk the list again.

    Practice · Build a singly linked list
  5. 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
Stage challenge

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
Which approach would you use?
The tally shows 4 robins and 2 wrens. The next entry is wren. What should the tally show now?

How does the name help you update just one total?

Stage 2 · Strings and two pointers

Count repeated characters, walk inward from both ends of a string, and combine two sorted lists.

  1. Character frequency lab

    Update a tally each time a character appears. Use the final counts to describe the whole string.

    Practice · Counting a Character
  2. Reversing with two pointers lab

    Compare characters at opposite ends. Apply the same pair of moving indexes to reverse a string.

    Practice · String Reversal
  3. 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
Stage challenge

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
Which approach would you use?
Camera A has times [3, 8] and B has [5, 6]. You have already copied 3 and 5. Which time comes next?

Why is comparing just the two front times enough?

Stage 3 · Sorting, heaps and search

Put values in order, then use one comparison to rule out a whole range or branch.

  1. 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
  2. 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
  3. 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
  4. 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
Coding game · Write your own binary search →
Stage challenge

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
Which approach would you use?
You are looking for 18 seconds. Positions 2 through 8 are still possible. You read position 5 and see 21 seconds. Which positions still need checking?

How does reading one timestamp narrow the search for 18 seconds?

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.

  1. Stacks lab

    Write each edit above the previous one. Cross out the top edit each time the editor undoes a change.

    Practice · Stack
  2. 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
Stage challenge

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
Which approach would you use?
You pause the tart at step 4 to make a filling. You pause the filling at step 2 to make syrup. The syrup is ready. Which note do you take now?

Why does taking one note bring you back to the right recipe?

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.

  1. 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
  2. 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
  3. 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
Stage challenge

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
Which approach would you use?
Starting from CAT, you queue COT then BAT. You take COT from the front and discover COG. Where should COG go, and which word do you explore next?

How does the queue order help you find a shortest word ladder?

Stage 6 · Backtracking and dynamic programming

Build every possible selection, then see how saving a smaller answer can avoid repeated work.

  1. Backtracking with subsets lab

    Choose an item, explore that choice, then undo it to try another selection.

    Practice · Generate subsets
  2. Dynamic programming with Fibonacci lab

    Build each Fibonacci number from two earlier answers. Track exactly which values the next step needs.

    Practice · Fibonacci sequence
Stage challenge

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?

Take the challenge
Which approach would you use?
There are 2 ways to reach step 2 and 3 ways to reach step 3. How many ways reach step 4?

Which two groups of paths make up the total, and why can you add their counts?