Computer Science • Pseudocode

Trace Tables

Rows recorded: 0

Pseudocode

    Trace table

    No rows recorded yet.

    Explanation

    Pseudocode and flowchart notation

    Symbol or keywordMeaning
    ←Assignment: the variable on the left takes the value on the right, e.g. Total ← Total + Num.
    DECLAREDeclares a variable and its data type, e.g. DECLARE Count : INTEGER.
    INPUT / OUTPUTReads a value from the user, or displays a value on screen.
    IF … THEN … ELSE … ENDIFSelection: runs one branch or the other, depending on a condition.
    CASE OF … OTHERWISE … ENDCASESelection between several branches, by the value of one variable.
    FOR … TO … NEXTCount-controlled iteration: repeats a known number of times.
    WHILE … ENDWHILECondition-controlled iteration, tested before the loop body runs: the body may run no times at all.
    REPEAT … UNTILCondition-controlled iteration, tested after the loop body runs: the body always runs at least once.
    PROCEDURE / CALLDefines a named block of instructions, and runs it.
    FUNCTION … RETURNSDefines a named block of instructions that sends a value back to where it was called.
    DIV / MODInteger (whole-number) division, and the remainder after integer division.
    Array[index]One element of an array, by its position, e.g. Numbers[3].

    Flowchart shapes

    Rounded rectangle (terminator)The start or the end of the algorithm.
    Rectangle (process)An action or calculation, e.g. assigning a value to a variable.
    Diamond (decision)A yes/no question; the flow takes one branch or the other.
    Parallelogram (input/output)Reading in a value, or outputting one.

    The notation is Cambridge International's, as in its pseudocode guides for 9618 and 0478.

    Trace Tables — Explanation

    Each question is a past paper trace table: pseudocode from Cambridge International AS & A Level Computer Science (9618) Paper 2, or pseudocode or a flowchart from Cambridge IGCSE Computer Science (0478) Paper 2. Dry run the algorithm with the data given, and complete the trace table as you would on the printed paper.

    How to fill in the table. The table has the same rows as the mark scheme. In each row, write the value of any variable that changes, and any output. Leave a cell blank when its value doesn't change from the row above, as the mark scheme does. A row printed in grey is given in the question.

    Some answers use ∇ for a space, as the paper does: the ∇ button puts one in.

    Signed in, your tables are saved as you go: come back to any question and carry on where you left off. A question is done once you've submitted it with every row filled in; done questions are ticked in the list, and Random question picks one you haven't done yet.

    Set by your teacher. Questions your teacher has set you are marked in the list, and come up first. Each is worth one mark for every row you get right first time: a row you had to correct, or completed with a hint, gets no mark. If you had already done one before it was set, it starts again, fresh; after that you can have as many attempts as you like, and your best counts.

    Objective: use a trace table to dry run an algorithm written in pseudocode or as a flowchart, showing how each variable changes and what is output (0478 syllabus 7, Algorithm design and problem-solving: complete a trace table to document a dry run; 9618 syllabus 12.3, Program testing and maintenance: dry runs).

    Where this fits

    • AP: AP Computer Science Principles Goes beyond AP Computer Science Principles: Uses Cambridge pseudocode, not the AP reference sheet's, but the tracing transfers.
    • AQA: AQA A Level Computer Science (7517)
    • Cambridge: Cambridge IGCSE Computer Science (0478); Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618); Cambridge A Level Information Technology (9626); Cambridge AS Level Information Technology (9626) Goes beyond Cambridge A Level Information Technology (9626): Trace tables aren't named in 9626; reading pseudocode and flowcharts and finding their errors (4.1-4.2) is. Goes beyond Cambridge AS Level Information Technology (9626): Trace tables aren't named in 9626; reading pseudocode and flowcharts and finding their errors (4.1-4.2) is.
    • IB: IB Computer Science HL; IB Computer Science SL Goes beyond IB Computer Science HL: IB uses Java or Python, not Cambridge pseudocode, but dry running with a trace table is the same skill. Goes beyond IB Computer Science SL: IB uses Java or Python, not Cambridge pseudocode, but dry running with a trace table is the same skill.
    • Pearson Edexcel International: Edexcel International GCSE Computer Science (4CP0)
    • USDP: USDP Computer Science

    Trace Tables — Key Terms

    Key concepts in English, with te reo Māori, Chinese (Simplified) and Korean.

    EnglishTe reo Māori中文(简体)한국어What it means on this page
    Algorithmhātepe算法알고리즘A precise sequence of steps for solving a problem — what both the pseudocode and the flowchart on this page describe.
    Pseudocodeno attested term伪代码의사코드A structured, language-independent way of writing an algorithm, using keywords like IF, FOR and WHILE.
    Flowcharthoahoa rerenga流程图순서도A diagram that shows an algorithm using standard shapes for start/end, actions, decisions and input/output.
    Variabletāupe变量변수A named location that holds a value which can change while the algorithm runs — the columns of the trace table.
    Trace tableno attested term追踪表추적표A table used to record the value of each variable, row by row, as an algorithm is dry-run by hand.
    Dry runno attested term人工跟踪수동 실행Working through an algorithm by hand, one step at a time, to see what it does — exactly what this page trains.
    Iteration (loop)koromeke循环(迭代)반복(루프)A block of steps that repeats — FOR, WHILE or REPEAT — while or until a condition holds.
    Selectionno attested term选择结构선택 구조A decision point where the algorithm follows one of two or more branches — IF or CASE, or a decision box in a flowchart.
    Sequenceraupapa顺序结构순차 구조Steps carried out one after another, in the order they are written or drawn.
    Arrayhuānga数组배열An ordered list of values, all referred to by one name and an index, e.g. Numbers[3].
    Inputtāuru输入입력A value read into the algorithm from outside — for example, typed in by the user.
    Outputhuaputa输出출력A value the algorithm produces — for example, displayed on the screen.
    Functiontaumahi函数함수A named block of instructions that returns a value back to where it was called.
    Procedurearamahi过程프로시저A named block of instructions that is run (CALLed) but does not return a value.
    Data typemomo raraunga数据类型자료형What kind of value a variable can hold — for example INTEGER, REAL, STRING or BOOLEAN.
    BooleanPūreana布尔불A value that is only ever TRUE or FALSE — often the result of a condition tested in a decision.
    Conditionno attested term条件조건An expression that is tested and evaluates to TRUE or FALSE, used to control a selection or iteration.
    Mark schemeno attested term评分标准채점 기준The official Cambridge document that gives the accepted answers this page’s trace tables are transcribed from.

    On the te reo Māori column. Terms marked as gaps have no attested equivalent in the sources checked — Karaitiana Taiuru's Dictionary of Māori Computer and Social Media Terms, Paekupu, the Reserve Bank's te reo financial glossary, NZQA and Te Aka. No coinage is printed as though it were established; where a class needs one, commission it from Te Taura Whiri i te Reo Māori and credit the translator. Te reo Māori is not italicised and takes no plural "s".