A practical way to study data structures and algorithms

Data structures and algorithms are best learned by alternating between explanation, implementation and problem-solving. Reading a solution can make an idea feel familiar without showing whether you can choose the right approach or write it correctly. Each study session below therefore produces something you can check: a complexity analysis, a working implementation, a test suite or a reasoned solution.

This plan takes eight weeks at about five hours a week. It suits a learner who knows basic programming: variables, loops, functions and arrays. If your course has different prerequisites or a set assessment schedule, use its official outline to reorder the topics. The plan is for building subject knowledge, not a prediction of any particular exam.

Set up your starting point

Choose one programming language and use it throughout. Gather your course outline or topic list, a place to write complexity notes, and a way to run tests. At the start, attempt one small problem involving arrays and one involving recursion. Spend no more than 25 minutes on each. Record where you got stuck: understanding the prompt, selecting a structure, reasoning about runtime, or implementing and testing.

Keep a short revision board organised by topic. Each section should hold definitions and conditions you tend to forget, rather than copied chapters. Link each idea to code or a worked example. A board on this topic ends up looking like this:

Data Structures and Algorithms Arrays, hashing and complexityStudy
FoundationsArrays, hashing and complexity5 sections · 3 columns
Growth rates
  • O(1) — a fixed number of operations, independent of input size
  • O(n) — one pass over n items
  • O(n²) — often two nested passes over n items
Binary search
  • Requires sorted data or a monotonic condition
  • O(log n) comparisons
  • For inclusive bounds, maintain lo ≤ answer ≤ hi and make each update shrink the interval
Dynamic arrays
  • Index access is O(1)
  • Append is amortised O(1); an individual resize can take O(n)
  • Insert or delete near the front is O(n) because elements shift
Testing edge cases4 due
  • Empty input and one element
  • Duplicate values
  • Already sorted and reverse-sorted input
  • Smallest and largest allowed values
Hash tables

Expected O(1) lookup, insertion and deletion with a suitable hash function and controlled load factor; worst-case O(n) when many keys collide.

Your weekly rhythm

Use four sessions each week: two of 75 minutes, one of 90 minutes and one of 60 minutes. That is five hours. Leave a day between at least two sessions if you can. At the start of each session, spend five minutes recalling last session’s key ideas without notes. At the end, write down one question you can now answer and one point that still needs work.

A due queue helps prevent revision from becoming a vague intention. Review cards due today before starting new material, and keep the review short: answer first, check the answer, then grade how well you recalled it. A due queue for several DSA boards might look like this:

Due today
Complexity and arrays8 due
Trees and heaps5 due
Graphs and traversalClear

The eight-week plan

Week 1: Complexity, arrays and strings

Session 1 — 75 minutes: Learn to describe time and space complexity in terms of input size. Compare a single loop, nested loops and repeated halving. For each example, state what n represents and identify the dominant growth term; do not just count lines of code.

Session 2 — 75 minutes: Implement array traversal, prefix sums and two-pointer scans. For each, write the invariant or condition that makes the method work. Test empty, single-item and duplicate-containing inputs.

Session 3 — 90 minutes: Solve two array or string problems without looking at solutions. After each, write a brief explanation of the approach and analyse time and auxiliary space. If stuck for 25 minutes, inspect a hint, close it, and finish the implementation yourself.

Session 4 — 60 minutes: Revisit the week’s errors. Make concise cards for facts you need to recall, such as when a two-pointer method is valid. Rework one problem from a blank file.

Week 2: Linked lists, stacks, queues and hashing

Session 1 — 75 minutes: Implement a singly linked list and trace insertion, deletion and search. Compare the cost of reaching an index in a linked list with indexed access in a dynamic array.

Session 2 — 75 minutes: Implement a stack and queue, then use them in a balanced-brackets check and a simple breadth-first traversal of a tree. Explain why each operation belongs at the chosen end of the structure.

Session 3 — 90 minutes: Practise hash maps and sets. Solve one frequency-counting task and one task that uses a set to detect duplicates or record visited items. State the expected-time assumption and what collisions mean.

Session 4 — 60 minutes: Reimplement one structure from memory, test empty and repeated-value cases, and update your board with operations and their complexities. Don’t memorise a complexity table without understanding what operations cause it.

Week 3: Recursion, trees and heaps

Session 1 — 75 minutes: Work through recursion using a base case, a smaller subproblem and a return step. Trace calls for a small input and identify the maximum call-stack depth.

Session 2 — 75 minutes: Implement depth-first tree traversals: preorder, inorder and postorder. For each, write the visit order on a small tree before running the code. Practise a level-order traversal with a queue.

Session 3 — 90 minutes: Learn binary search trees and binary heaps. Implement heap insertion and removal, or use your course language’s standard priority queue and explain its operations. Remember that a heap is not a fully sorted array.

Session 4 — 60 minutes: Solve one tree problem and one priority-queue problem. Compare recursive and iterative approaches where relevant; note any stack-space cost.

Week 4: Sorting and searching

Session 1 — 75 minutes: Trace insertion sort and merge sort on short arrays. Explain why merge sort takes O(n log n) time and typically uses O(n) extra space for arrays.

Session 2 — 75 minutes: Study quicksort and its partition step. Explain why its average time is O(n log n), while its worst case can be O(n²), depending on pivot choices and input. Run tests on sorted and reversed inputs.

Session 3 — 90 minutes: Practise binary search and its variations, such as finding the first position that satisfies a monotonic condition. Write down the loop invariant and test boundary cases carefully.

Session 4 — 60 minutes: Given several small problem descriptions, choose a suitable search or sorting method and justify the choice. Focus on constraints, required output and whether the input is already ordered.

Week 5: Graphs

Session 1 — 75 minutes: Represent a graph with an adjacency list and an adjacency matrix. Compare space use: an adjacency list is generally suited to sparse graphs; a matrix allows direct edge checks but uses O(V²) space.

Session 2 — 75 minutes: Implement breadth-first search and depth-first search. Track visited vertices so cycles do not cause repeated visits. Practise on a disconnected graph as well as a connected one.

Session 3 — 90 minutes: Work on shortest paths. Use BFS for unweighted graphs; study Dijkstra’s algorithm for graphs with non-negative edge weights. Do not apply Dijkstra’s algorithm when negative edge weights are allowed.

Session 4 — 60 minutes: Solve a graph problem and explain the representation, traversal or algorithm choice, complexity and any assumptions. Add missed edge cases to your notes.

Week 6: Greedy methods and dynamic programming

Session 1 — 75 minutes: Study greedy algorithms through examples. For each proposed greedy choice, ask why making it now still permits an optimal solution; a plausible local choice is not proof.

Session 2 — 75 minutes: Build a dynamic-programming solution from a small problem: define the state, recurrence, base cases and evaluation order. Draw the dependency graph before writing code.

Session 3 — 90 minutes: Solve one one-dimensional DP problem and one grid or two-dimensional problem. Start with a direct recursive definition, then add memoisation or tabulation and compare repeated work.

Session 4 — 60 minutes: Explain each DP state in a sentence, then test the smallest inputs. If the recurrence is unclear, revisit the definition rather than trying to memorise code.

Week 7: Mixed practice and targeted repair

Session 1 — 75 minutes: Complete two mixed problems under a time limit you choose. For each, spend a few minutes identifying the relevant structure before coding.

Session 2 — 75 minutes: Review failed or incomplete solutions. Categorise each miss: concept, algorithm choice, complexity, implementation, or testing. Repair the underlying issue, not just that particular answer.

Session 3 — 90 minutes: Revisit the two weakest topic areas. Do one fresh problem in each, then explain the solution aloud or in writing without using notes.

Session 4 — 60 minutes: Review due cards and redo one earlier problem from a blank file. Compare the current solution with your first attempt and record what changed.

Week 8: Consolidation

Session 1 — 75 minutes: Take a mixed, timed practice set using questions at a level appropriate to your course. Use the time limit as a practice constraint, not as a claim about any specific assessment.

Session 2 — 75 minutes: Mark your work against correctness, explanation, complexity and edge cases. Keep these as your own revision categories, not assumed official marking criteria.

Session 3 — 90 minutes: Re-solve the most instructive missed problem. Write a clean explanation, prove the key step or invariant, and test boundary cases.

Session 4 — 60 minutes: Review remaining due cards and make a short next-steps list based on actual errors. Check your course outline for any required topics not covered here.

Adjust the plan to your weak areas

Don’t give every topic equal time once you have evidence about where you struggle. Use the last two weeks’ practice results to choose a repair target. A topic is worth revisiting if you repeatedly choose an unsuitable structure, cannot justify a recurrence, or get complexity and edge cases wrong. A MySummaries section picker can focus a short lecture on the topic with the most missed cards or lost practice marks:

New lecture
How long have you got?5 min10 min15 min20 min
Dynamic programmingGraph traversalHash tablesSorting

Dynamic programming · Struggling — getting 4 of 9 cards wrong, scored 58% in recent practice

Generate lecture ideas

At the end of each week, keep a small error log. Record the prompt type, the mistake, the correction and a trigger for recognising that pattern next time. For example: “Used DFS for an unweighted shortest-path question; use BFS when each edge has equal cost.” This turns a vague weak area into a decision you can practise.

A summary of practice results can help you decide what to work on next. In a weak-topic view, “times” should mean appearances in your own practice set, not how often a topic appears in an exam:

Where marks go missing
58%Dynamic programming7×
67%Graph traversal6×
84%Arrays and hashing9×

Keep the plan workable

If five hours is too much in a particular week, preserve the review session and reduce the number of new problems. If you have more time, add a fresh problem and a written explanation rather than extending passive reading. Don’t move on just because the week has ended: if you cannot explain the central idea and pass basic tests, use the next week’s first session to repair it.

For each problem, practise a repeatable sequence: restate the input and output, note constraints, choose a structure, outline the method, check correctness, analyse complexity, then test edge cases. This sequence helps distinguish a knowledge gap from a coding slip and makes practice useful even when you do not finish a problem.

How MySummaries helps

Build a revision board from your own notes, slides or photographed handwritten material, then use it to create spaced-repetition cards, written practice and short audio lectures. For this plan, that means keeping complexity, algorithm conditions and your own recurring mistakes together, then directing the next review session towards what your practice shows needs work. Start at MySummaries.