Professor Turing

Study guides

How to study for a computer science exam

Last updated: 2026-11-24

To study for a computer science exam, work problems on paper without a computer: trace code by hand, write solutions from memory, then compare with the answer, and spread this over several days instead of rereading slides the night before. In the studies we read, students who practiced recalling material kept more on later tests than students who studied it again, and in one study of a first programming course, students who traced code well also tended to write code well.

Start learning No account needed

1. Know what the exam asks for

Intro CS exams tend to mix four kinds of question: read code and say what it does or prints (tracing), find the bug, write a function, and explain a program or an idea in plain English, such as why one approach takes fewer steps than another. Check the syllabus and past exams for the format. Some courses use pencil and paper, some are open book, and some allow a notes sheet. The course pages we read agree on one point: practice in the format you will be tested in. UW's CSE 123 page says to do practice problems by hand on paper, and Stanford's CS111 page says to write out solutions under test-like conditions. We found no study of what CS exams test, so the four kinds above are our description, and your instructor's handout beats it.

2. Trace code by hand until you can predict the output

Take a short function and a sample input, and write a table with one row per pass through the loop and one column per variable. Fill it in with a pencil before you run anything, then run the code and compare. A mismatch tells you which step you misread.

Here is one worked through. A sorted list of 15 numbers, [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44], and a binary search for 35:

def binary_search(a, target):
    lo, hi = 0, len(a) - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if a[mid] == target:
            return mid
        if a[mid] < target:
            lo = mid + 1
        else:
            hi = mid - 1
    return -1
checklohimida[mid]
1014723
28141135

The second check finds 35, so the function returns index 11 after 2 checks. Because 23 is less than 35, lo moves to mid + 1, which discards the left half including index 7.

Now change one thing. A common slip is writing while lo < hi instead of while lo <= hi. Trace the correct version and the changed version on [1, 3, 5], searching for 5. The correct loop returns index 2. The changed loop checks index 1 (value 3), moves lo to 2, sees that lo equals hi, leaves the loop and returns -1, though 5 is in the list. You would find that on paper, and a "find the bug" question often looks like this.

The same table answers a question about cost. Each check throws away half of what is left, so the checks needed are at most the number of times you can halve the list. We ran the code on all present and absent targets in lists of 1,000 and 1,000,000 items. The most checks needed were 10 and 20, against up to 1,000 and 1,000,000 for a scan from the front. The script is scripts/cs-exam-worked-example.py in the Professor Turing repository, and it asserts each number above.

Lopez, Whalley, Robbins and Lister gave a programming exam to students after one semester. Scores on tracing questions correlated with scores on code-writing questions, and so did scores on "explain in plain English" questions. That is a correlation, not proof that practicing tracing improves writing, so for your exam it is our suggestion to start there.

3. Write solutions from memory, then compare

Pick a problem from lecture, section or a past exam. Close the notes and solve it on paper. Then open the solution and mark what you missed, such as an off-by-one in a bound or a missing return. Roediger and Karpicke had students study passages and then either restudy them or take recall tests. After 5 minutes restudying did better. After 2 days and a week the tested group kept substantially more, even though restudying made students more confident. Their material was prose, not code, so for programming this is our reading of the evidence.

For the general method, see how to test yourself.

4. Mix problem types and spread it over days

Cepeda and colleagues combined 839 assessments of spacing in 317 experiments. The gap that gave the most retention grew as the time until the test grew. We found no tested schedule for a single exam, so a reasonable start is to return to each topic on at least two different days and to give the topics you missed most the most sessions. Within a session, mix recursion, loops, arrays and complexity questions instead of finishing one topic at a time. Rohrer and Taylor found that college students who practiced mixed problem types scored much higher a week later than students who practiced one type at a time. Their problems were math, so for CS this is our suggestion. The UW CSE 121 page links to this same paper.

For the wider plan across several courses, see how to study for finals.

Can I study by running code instead?

Running code is useful for checking a trace, and it is a poor stand-in for an exam if your exam is on paper. Predict the output first, write it down, then run it. We found no study comparing computer practice with paper practice, so the UW and Stanford advice to practice in the exam format is a course recommendation, not a measured result.

What the sources found, and their limits

Roediger and Karpicke, 2006. Two experiments with students who studied prose passages, then restudied or took one or three free-recall tests with no feedback. After 5 minutes restudying did better; after 2 days and a week testing gave substantially greater retention. Limits: prose in a lab, not code, and we read the abstract record, not the full paper. Source: Europe PMC record, 2006, abstract read through the Europe PMC API on 2026-11-23.

Cepeda, Pashler, Vul, Wixted and Rohrer, 2006. A meta-analysis of 839 assessments of distributed practice in 317 experiments in 184 articles. The study gap that gave maximal retention increased as the time until the test increased. Limits: verbal recall tasks, and we read the abstract only. Source: Europe PMC record, Psychological Bulletin, 2006, abstract read through the Europe PMC API on 2026-11-23.

Rohrer and Taylor, 2007. Two experiments with college students practicing math problems. Spread practice beat massed practice, and mixed problems beat one type at a time, on a test a week later. Limits: math only, one test a week later, and the abstract page gives no sample sizes. Source: Instructional Science, 2007, abstract record, read on 2026-11-23.

Lopez, Whalley, Robbins and Lister, 2008. Student responses to an exam after one semester of programming. Tracing scores correlated with code-writing scores, and "explain in plain English" scores correlated with code writing. A regression suggested a hierarchy of tasks. Limits: a correlation, not an experiment, and we read the abstract only. Source: ICER 2008 abstract record at UTS, read on 2026-11-23.

Course pages. Stanford CS111, Advice About Exams, UW CSE 123, Exam Studying and UW CSE 121, Tips for the Final Exam, read on 2026-11-23. They are advice for one course each. Apart from the CSE 121 link to the Rohrer and Taylor paper and an unnamed calculus study mentioned on the CSE 123 page, they cite no research.

How Professor Turing helps

Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start. It's an AI tutor, free to try.

Bring a program you are studying, such as the binary search above. Its first reply asks about your attempt, such as what you tried or where it stops making sense, before it teaches anything. If you send an answer with no steps, such as "it returns 11", it asks how you got there instead of saying right or wrong, and when you stay stuck it changes its approach and makes the next step smaller. Later in a session it can offer a short test without help, scored apart from the tutoring, so you can tell what you can do alone from what the tutor carried you through.

It cannot see handwriting or photos, so do your trace tables on paper yourself and say what you found. You must be 18 or older. Guest conversations are deleted 7 days after your last activity; with an account they are kept while the account is active.

FAQ

Should I memorize syntax? Know the syntax your exam will make you write by hand, and check the syllabus for what is allowed on a notes sheet. We found no study of how much syntax students need to memorize.

How do I practice a "find the bug" question? Take a working function, change one operator or bound, and trace it on a small input, as with lo < hi above. Then do the same for a function a classmate changed.

Can the tutor check my trace table? Only the steps you type. It cannot see handwriting or a photo of a table, so type what you found, and check the table yourself by running the code.

Start with what you're working on

Tell the tutor which topic you are studying and let it ask you the questions.

Start learning No account needed

See also: all study guides