How to Study for a Computer Science Exam: Code, Trace, Repeat

If you want to know how to study for a computer science exam, start with one fact: CS exams test what you can do with code, not what you can recognize on a slide. You will be asked to predict output, write a function from scratch, and explain why one algorithm beats another. This guide shows you how to practice each of those skills, with a worked tracing example and a 7-day plan you can start tonight.

Why rereading slides fails on a computer science exam

Rereading feels productive because the slides look familiar. But familiarity is not the same as ability. You can read a merge sort slide ten times and still freeze when you have to write it on paper with no editor and no autocomplete.

Research backs this up. In a well-known 2006 study, students who tested themselves on a passage remembered much more two days and a week later than students who reread it, even though the rereaders felt more confident.

A CS exam asks you to produce something. You produce an output, a block of code, or a short argument about running time. The only way to get better at producing is to practice producing. That is the same reason the advice in how to study for a genetics exam is to work problems instead of reading notes. Computer science works the same way.

Sort the exam into code writing, tracing, and theory

Before you study, look at the syllabus, the practice exam, or what your instructor said in class. Most CS exams split into three kinds of questions:

  • Tracing. "What does this code print?" or "What is the value of x after line 6?"
  • Code writing. "Write a function that reverses a linked list."
  • Theory. Definitions, Big-O, when to use a hash table versus a tree, what a stack overflow is.

Write down roughly what share of points each kind is worth. If half the exam is code writing, half your study time should be code writing. Theory is the easiest part to read about, so it is easy to give it more time than it is worth.

Trace code by hand until you can predict every output

Tracing means running the code in your head, one line at a time, and writing down every variable as it changes. Here is a short example. Cover the answer and try it first.

The code: x = 0, then for i in range(1, 5):, and inside the loop, if i % 2 == 0: x += i, otherwise x -= 1. What is x at the end?

Write one line per loop pass:

  1. i = 1: 1 is odd, so x goes from 0 to -1.
  2. i = 2: 2 is even, so x goes from -1 to 1.
  3. i = 3: 3 is odd, so x goes from 1 to 0.
  4. i = 4: 4 is even, so x goes from 0 to 4.

The loop stops before 5, so the answer is 4. Notice the two traps: range(1, 5) does not include 5, and the odd branch subtracts 1, not i. Most tracing mistakes come from details like these, not from hard logic.

Practice with this routine:

  • Take a snippet from your lecture notes or a lab.
  • Trace it on paper and write your predicted output.
  • Only then run it on a computer to check.
  • If you were wrong, find the exact line where your trace went off.

Pay extra attention to off-by-one loop bounds, integer division, references versus copies, and recursion. For recursion, draw each call as a box with its own variables, and cross it off when it returns.

Write programs on paper without an IDE

On most written exams you get a pen and nothing else. No syntax highlighting, no error messages, no running the code to see if it works. If all your practice happens in an editor, you are training a different skill than the one being tested.

Pick a problem from a past lab or homework. Close your laptop. Write the full solution on paper, including the function signature and return statement. Then type it in exactly as written and run it. Count the bugs. Each bug is a note for your review list.

Before writing any code, spend a minute on a plan in plain words: "Walk two pointers from each end, swap, stop when they meet." On the exam, write that plan above your code too. If your course gives partial credit, a clear approach shows what you meant even when the syntax slips.

Drill data structures, algorithms, and Big-O with active recall

Theory questions reward quick, accurate recall. You should be able to answer these without looking anything up:

  • What is the average and worst case lookup time for a hash table?
  • Why is binary search O(log n)? (Each step cuts the remaining range in half.)
  • When would you pick a linked list over an array?
  • What does a stack do that a queue does not?

Active recall means you try to answer before you see the answer. This is the part of CS studying where a practice quiz fits well. A 2018 meta-analysis found that practice testing transfers best to application and inference questions and least to problems with worked examples. So quiz the ideas, and keep code practice on paper.

Diagram of a computer science study loop: trace code, write code from a blank page, quiz the ideas, fix the misses

With Study Shot, you take a photo of a page from your textbook, your notes, or a whiteboard, and it writes multiple-choice questions about it. Each question has four choices and one right answer. After you pick an option and press Check answer, you see whether you were right, the correct answer, and a short explanation.

Here is a workflow for a data structures chapter:

  1. Photograph the page that compares arrays, linked lists, and hash tables. Hold it flat and fill the frame.
  2. Pick 10 questions and the Tiered level. Tiered is a ladder: basic questions first, then intermediate, then advanced.
  3. Answer one question at a time and read every explanation, even on the ones you got right.
  4. On the results screen, check your score for each level. If Basic is strong but Advanced is weak, you know the definitions but not how to apply them.
  5. Read the "Look at these again" list, which shows the questions you missed with your answer and the right answer.
  6. Retake the quiz from your library two days later.
Study Shot home page feature cards: Basic to Advanced, 50 languages, and up to 20 questions with four choices

Two honest limits. Study Shot only writes multiple-choice questions, so it cannot check code you write. And the questions are written by an AI model, which can make mistakes. Use the explanation to check the reasoning against your notes, and if a question looks wrong, use Report a problem with this question.

Work past exams and practice problems under timed conditions

Past exams are the closest thing to the real test. They show you the format, the difficulty, and what your instructor cares about. Ask for them, check the course site, or ask students who took the class before.

Take at least one full past exam with a timer, paper only, no notes. Then grade it honestly. Sort every lost point into tracing, writing, or theory. That tells you where your last few days should go.

How to study for a computer science exam in 7 days

This plan assumes about two hours a day. Shift the balance based on how your exam is weighted. For a shorter version, see the structure of this 5-day plan.

  • Day 1: List every topic. Sort exam questions into tracing, writing, and theory. Take a short diagnostic quiz on each chapter to find weak spots.
  • Day 2: Tracing. Ten snippets from lectures and labs, traced on paper and then checked by running them.
  • Day 3: Data structures. Quiz yourself on each structure's operations and costs. Write one implementation on paper, such as a stack with push and pop.
  • Day 4: Algorithms and Big-O. Trace sorting and searching algorithms on a small array by hand. Write the running time of each and say why.
  • Day 5: Code writing. Three problems on paper, then typed in and tested. Log every bug.
  • Day 6: Full past exam, timed. Grade it and sort every lost point.
  • Day 7: Fix the weakest category from Day 6. Retake your missed quizzes. Stop early and sleep.

The same idea of building the plan around question types shows up in our guide on how to study for a philosophy exam, which is useful if your CS course includes logic or proofs.

Frequently asked questions

Can a practice quiz replace writing code?

No. A multiple-choice quiz checks whether you know the ideas, and testing transfers least to worked problems. Write and trace code on paper, and use the quiz for terms, trade-offs and running times.

How do I memorize algorithms without just memorizing code?

Learn the idea in one sentence, then trace it by hand on a small example, then write it from that idea. If you can explain why each step exists, you can rebuild the code in whichever programming language your course uses.

Should I practise with past exams or new problems?

Start with past exams, because they match your instructor's format and topics. Add new problems once you have worked through them.

How do I study for a CS exam when I am bad at math proofs?

Start by learning the standard proof patterns your course uses, like induction and contradiction, and copy the structure of worked examples. Then write proofs for small cases yourself and compare them line by line with the model answer.

Get started

Try Study Shot: it is free to start. Photograph the page you are studying tonight and get 10 practice questions on it, from basic to advanced.

0 likes

Comments

No comments yet.

Sign in or make an account to comment.