50% lifetime discountCLASSEVA50
How to Revise for a Coding Exam
Exam Preparation

How to Revise for a Coding Exam

By Jonas8 September 202610 min read
Key Takeaways
How to revise for a coding exam differs from regular programming practice: the exam removes your IDE, autocomplete, and compiler, so revision must simulate those conditions.
The core skill is writing code by hand and tracing execution mentally. Students who only read code fail when required to produce it cold.
Build a hand-trace table for every algorithm: columns for each variable, rows for each execution step. This makes bugs visible before the exam.
Prioritize writing complete functions from memory, tracing loops and recursive calls on paper, and completing past papers with no IDE and under timed conditions.
A four-week revision plan: week 1 tracing, week 2 hand-writing functions, week 3 algorithm patterns, week 4 timed past-paper practice.

Reading code feels like revision. It is not. When you scroll through a solution to a sorting algorithm with your IDE open, your brain registers the logic as familiar and calls that understanding. The exam removes the IDE, the autocomplete, and the ability to run the code, and suddenly “familiar” collapses into “I cannot write a single line from memory.” That is the gap that cs exam revision must close.

The fix is straightforward but uncomfortable. You practice writing code by hand, tracing execution without running anything, and predicting output step by step. These are the exact tasks the exam sets, and they only become fluent through deliberate practice under exam-like conditions. Building that fluency is what this guide covers.

Why Reading Code Fails as Exam Revision

Reading code trains recognition, not production. When the source is visible, your brain can verify whether a line looks right without constructing it. That verification process feels identical to understanding, but it never builds the ability to write the line from scratch. The exam tests production. Reading code prepares you for recognition. The two skills transfer poorly to each other.

What the IDE Hides from You

A modern IDE removes four layers of difficulty that the exam puts back. It autocompletes syntax so you never have to recall it. It highlights errors so you never have to notice them. It runs code so you never have to trace execution mentally. It offers documentation on hover so you never have to remember what a function does. Remove all four, and the coding exam demands a skill set that most students have never practiced.

Coding with an IDE

  • Autocomplete suggests syntax and method names
  • Error highlighting catches mistakes immediately
  • Run button verifies logic at each step
  • Debugger steps through execution automatically
  • Documentation available on hover

Coding Exam on Paper

  • Syntax recalled from memory only
  • No error feedback until the examiner marks it
  • Logic traced mentally, line by line
  • Execution followed by hand through loops and calls
  • All method behaviors recalled without reference

What Coding Exams Actually Test

University programming exams typically assess three abilities. First, code production: writing a correct function or algorithm from a specification. Second, code comprehension: reading a provided piece of code and predicting its output, identifying a bug, or explaining its behavior. Third, algorithm reasoning: analyzing time complexity, tracing a sorting or search procedure, or adapting a known algorithm to a new constraint. All three require a tight mental model of execution, built by practice without a compiler.

Check Your Module's Past Exam Format

Before building your revision plan, look at three or four past exam papers from your module. Note the ratio of write-code questions to trace-code questions. Some modules weight output prediction heavily; others focus on writing complete functions. Your revision time should mirror that weighting. Your department or lecturer will usually post past papers; if not, ask directly.

How to Practice Writing Code by Hand

Writing code by hand means taking a function specification or algorithm description and producing correct, runnable code on paper or in a plain text file, without reference to notes, without running it, and without an IDE. The goal is not perfect code on the first attempt. The goal is to identify exactly where your knowledge breaks down, then target those gaps.

How to Start a Hand-Writing Session

Pick a function you believe you understand. Close everything. Write it from memory on paper, including the function signature, variable declarations, loop structure, and return statement. Do not stop to look anything up. When you get stuck, mark the line, skip it, and keep going. After finishing, open your reference and compare line by line. Every line you marked or wrote incorrectly is a specific gap in your recall.

Repeat the function immediately, this time fixing each gap you found. The second attempt should be cleaner. Repeat a third time the next day to test whether the correction held. This three-pass method follows the spacing principle that retrieval after a delay consolidates memory more durably than repeated immediate review, which is consistent with the evidence in Dunlosky et al. (2013).

IDE Support Layers versus Exam ConditionsFour rows comparing what an IDE provides on the left against what the exam requires on the right. Each row animates in sequentially: autocomplete, error highlighting, run button, and documentation hover.Four Layers the Exam RemovesIDE providesExam requiresAutocompletesyntax and method names suggestedSyntax recalled from memoryno prompts availableError highlightingmistakes flagged instantlyErrors spotted by tracingno feedback until markingRun buttonlogic verified instantlyLogic traced mentallyexecution followed line by lineHover documentationmethod behavior availableBehavior recalled from memoryno reference available
Each IDE layer becomes a gap in your exam performance if you never practiced without it. Revision that removes these layers closes those gaps before the exam does.

Common Mistakes When Writing Code on Paper

Four patterns come up repeatedly when students first practice writing code by hand. Off-by-one errors in loop bounds are the most common: a loop that should run from index 0 to n-1 gets written as running to n. Incorrect base cases in recursive functions appear when the recursive structure is understood but the stopping condition was always checked by running the code rather than reasoned through. Missing return statements in branching functions, where the IDE would flag an unreachable path, appear because no error feedback exists on paper. Confusion between assignment and comparison operators shows up when syntax is recalled from muscle memory in an IDE context rather than explicitly.

All four of these mistakes share the same cause: the IDE was silently compensating for gaps in your knowledge. Catching them on paper during revision means they will not appear on the exam.

How to Trace Code Execution Step by Step

Tracing code execution means stepping through a program mentally, tracking the state of every variable at each line, and predicting output without running the code. This skill sits at the center of coding exam revision because output prediction and bug identification questions both require it. Students who can write code but cannot trace it produce answers that look plausible but contain reasoning errors the examiner catches immediately.

Building a Hand-Trace Table

A hand-trace table gives your mental model structure. Create one column for the current line number, one column for each variable in scope, and one column for any output or return value. Then step through the code row by row, updating each cell when the corresponding value changes. The table makes every state transition explicit and auditable.

Hand-Trace Table: Sum Loop Worked ExampleA table with columns for line number, variable i, variable total, and output. Six rows animate in sequentially, each showing the state after executing one line of a loop that sums integers from 1 to 4. The final row shows total equals 10.Hand-Trace Table: Sum Looptotal = 0for i in range(1, 5): total = total + i # sums 1+2+3+4Lineitotalnotetotal=0--0initialisefor i=110loop startstotal=0+111first passfor i=221second itertotal=1+223accumulatetotal=3+447 → 103+4 = 7... waitloop endsdone101+2+3+4 = 10
Each row updates one variable change. Tracking states row by row makes the exact moment of a bug visible. Examiners set trace questions precisely because this table does not lie about what you know.

The hand-trace table removes ambiguity. When you read a loop mentally and think “yes, that looks right,” you are recognizing a pattern. When you fill in each cell of the table, you are executing each operation. The distinction shows up in every case where a subtle off-by-one or incorrect accumulation hides behind a familiar structure.

Tracing Loops and Conditional Branches

Loops and conditional branches require a second tracing method alongside the variable table: tracking which path through the control flow executes for a given input. Draw a simplified flowchart with each branch labeled. Then annotate which path your specific test input follows. This works particularly well for nested conditionals, where reading the code gives a false sense of understanding while a concrete input reveals that your mental model skipped a branch.

Control-Flow Diagram: If-Elif-Else Execution PathsA top-to-bottom flowchart with a start node, three decision diamonds for x greater than 10, x greater than 5, and x greater than 0, each with yes and no branches leading to labeled result nodes. The path for input x equals 7 is highlighted in green.Control-Flow: Path for x = 7START: x = 7x > 10?7 > 10 = falseNoYes“large”Nox > 5?7 > 5 = trueYes“medium”NoNox > 0?Yes“small”“non-positive”x=7 exits here
Annotating which branch a concrete input follows forces you to reason about each condition explicitly. Drawing this diagram by hand during revision is more effective than reading the if-elif-else block and assuming you understand the flow.

The practice method is straightforward. Take a conditional block from your module's past papers or lecture notes. Choose two or three inputs that hit different branches. Trace each one through the flowchart by hand before writing a prediction. Check against the actual output. Any branch whose result surprises you is a gap in your mental model, not just in your memory. Research on the testing effect by Roediger and Karpicke (2006) shows that this kind of self-prediction before checking produces far more durable learning than reading a worked trace and confirming it looks right.

Trace Before You Write

For every function you plan to write in revision, trace an example input through it first. Confirm the expected output row by row in your trace table. Then write the function from scratch. If the output of your written function disagrees with your trace, you have either a logic error in the code or a tracing error in the table. Both are worth finding before the exam.

Which Algorithm Patterns to Prioritize

University CS modules typically test a consistent set of algorithm patterns in exams, regardless of the specific language or course title. Prioritizing revision time toward these patterns returns the highest marks per hour of practice. The patterns that appear most reliably are sorting algorithms, searching algorithms, recursion, and basic graph or tree traversal. MIT OpenCourseWare's Introduction to Algorithms course materials publish lecture notes and problem sets for these exact families, and working through the problem sets under timed conditions mirrors exactly the pressure of a written CS exam.

4
algorithm families cover most CS exam questions
Sorting, searching, recursion, and tree or graph traversal appear in the large majority of undergraduate programming exam papers.

Sorting, Searching, and Recursion

For sorting, the exam almost always asks you to trace an algorithm through a specific array rather than write it from scratch. Bubble sort, insertion sort, merge sort, and quicksort are the most common targets. The tracing skill matters more than memorizing pseudocode. Build a trace table for each sort on a five-element array you have never used before. If you cannot fill in the table correctly, you do not understand the algorithm well enough for the exam, regardless of how many times you read the pseudocode.

For searching, binary search requires careful attention to the boundary update rules. The most common exam error is incorrect mid-point calculation or incorrect boundary update on a miss. Trace binary search on an array of ten elements, locating a target that requires exactly three probes, and verify each boundary update. Then write the function from memory. This combination of tracing then writing closes the gap that reading alone leaves open.

Recursion demands the additional skill of tracking the call stack. Use your trace table to add a column for the current stack depth and a column for the return value of each frame. Trace through a recursive factorial or binary search implementation, noting when each frame returns and what value it hands back to the caller. This makes the base case visible as the point where depth stops increasing and return values start flowing back.

AlgorithmBubble sort
What to trace by handEach swap in each pass through the array
Common exam errorForgetting the inner loop decrements by pass number
AlgorithmBinary sort
What to trace by handEach probe: mid-point, comparison, boundary update
Common exam errorOff-by-one on boundary update after a miss
AlgorithmMerge sort
What to trace by handThe split tree and the merge steps
Common exam errorMerging incorrectly when one subarray is exhausted
AlgorithmRecursive binary search
What to trace by handCall stack depth, parameters per frame, return values
Common exam errorWrong base case or boundary passed to recursive call
AlgorithmTree traversal (in-order)
What to trace by handVisit order for a five-node example tree
Common exam errorConfusing in-order with pre-order or post-order

Trace each algorithm on a fresh example before writing the function from memory. The trace reveals which step your mental model handles incorrectly.

How to Debug Code on Paper

Debugging on paper starts with a trace table. Take the buggy function, provide a specific input, and trace execution row by row. The row where the computed value diverges from the expected value is the line containing the bug. This sounds mechanical, but students who skip to reading the code and hoping to “spot” the error waste time and miss bugs that only become visible through systematic state tracking.

For programming exam preparation, practice with functions that contain one deliberate bug: an off-by-one in a loop, a wrong comparison operator, a missing base case, or an incorrect return value. Your module's lecture notes or past papers likely contain debugging questions with known answers. Use them. If the bug you find matches the expected answer, your tracing is accurate. If not, retrace from line 1 rather than patch your existing trace.

The guide on revising for finals covers how to build tracing practice into a full revision schedule across multiple modules. For the subset of CS modules with formal algorithm analysis, the matrix multiplication worked example shows how careful step-by-step tracing applies to numerical algorithms as well.

A Four-Week CS Exam Revision Plan

Most students have between two and five weeks before their CS exam. The plan below distributes coding exam revision across four weeks to build all three skills, tracing, hand-writing, and timed practice, without front-loading any single technique.

Four-Week Coding Exam Revision PlanFour columns side by side, one per week, each animating in from left. Week 1 is tracing fundamentals, week 2 is hand-writing functions, week 3 is algorithm pattern drilling, and week 4 is timed past-paper practice under exam conditions.Four-Week Coding Exam Revision PlanWeek 1Tracing fundamentals Build trace tables for all loops in notes Trace sorting algos on 5-element arrays No writing code yet Tracing onlyGoal: trace any loopor recursion coldWeek 2Hand-writing functions Write 2 functions/day from memory on paper Check syntax after each attempt Repeat next day to fix gapsGoal: write any functionfrom spec, no IDEWeek 3Algorithm patterns Sort, search, recursion, traversal Trace then write each pattern Debug paper code: find deliberate bugsGoal: trace and writeall 4 families coldWeek 4Timed past papers Full past papers, no IDE, timed Trace model answers line by line Review gaps, final targeted drillGoal: exam conditionsfeel familiar
Each week builds on the previous. Tracing first means hand-writing is grounded in a correct mental model. Past papers last means exam conditions feel practiced, not surprising.

If you have fewer than four weeks, compress the plan by cutting week 2 in half: three days of hand-writing the most common function types your module tests, then move directly to the algorithm patterns week. The timed past-paper week should never be cut. Students who skip exam-condition practice and only drill in comfortable conditions consistently find the time pressure on exam day harder than the material itself.

Your subject calculators hub has tools that support the quantitative side of CS modules. For structuring open-ended written responses on the non-programming parts of your CS exam, the guide on structuring long-answer exam responses covers how to write clearly and efficiently under time pressure. If your CS module includes multiple-choice theory questions alongside coding, the multiple-choice exam preparation guide covers the elimination strategies that cut error rates on concept questions.

Working through algorithm traces with an AI tutor that asks you to predict each step, then shows you exactly where your trace diverges from correct execution, builds the skill faster than self-checking alone:

The university resources hub also has subject-specific tools for the mathematical and algorithmic topics that often sit alongside programming content in CS modules.

Key Takeaways

  1. Reading code trains recognition, not production. Coding exams test production: writing correct code from a specification, cold, without an IDE. Revision must close that gap by removing IDE support before the exam does.
  2. Practice writing code by hand: function signature, variable declarations, loop structure, and return statement, all on paper from memory. Mark every line where you get stuck; those marks become your study list.
  3. Build a hand-trace table for every algorithm you study. Create columns for each variable and fill in one row per execution step. The table makes off-by-one errors and incorrect accumulation visible without running the code.
  4. Trace conditional branches and loops by annotating which path a specific input follows through a control-flow diagram. Students who read conditionals and assume they understand the branching logic routinely miss exam questions that require following a concrete case.
  5. Prioritize four algorithm families for cs exam revision: sorting (bubble, insertion, merge, quicksort), binary search, recursion with call-stack tracking, and tree or graph traversal. These four cover the large majority of undergraduate programming exam questions.
  6. Debug on paper by tracing to the exact line where computed output diverges from expected output. Do not attempt to spot bugs by reading the function. Systematic tracing is faster and catches errors that reading misses.
  7. Complete the final week of revision under full exam conditions: no IDE, no internet, timed. Familiarity with exam conditions reduces the time pressure that catches well-prepared students off guard on the day itself.

Related articles

Try a free AI tutoring session