Pseudocode Overview

tags: - cocubes - pseudocode


Pseudocode Overview

Pseudocode tests algorithmic logic without forcing one programming language's strict syntax. The question is normally not "Can you memorise C/Java syntax?" It is "Can you execute an algorithm exactly?"

Vocabulary

Keyword Meaning
READ/Input take a value
DISPLAY/PRINT output a value
SET or = assign/update a variable
SEQUENCE execute statements in listed order
IF/THEN/ELSE conditional branch
FOR known-count loop
WHILE repeat while condition is true
REPEAT-UNTIL body runs first, then condition is checked
CASE choose among alternatives
MOD remainder
DIV integer quotient

The only reliable method

Never "read it in your head" for a nontrivial trace. Use [[04_Pseudocode/Dry_Run_Method|the dry-run table]]. A 10-second table prevents most wrong answers.

Main traps

  • Updating a variable and then using its new value in the next line.
  • Confusing x = x + 1 with a comparison.
  • Forgetting that a loop bound can be inclusive or exclusive.
  • Forgetting integer division.
  • Attaching ELSE to the wrong IF.
  • Continuing a recursion past its base case.
  • Assuming array indexing when it is explicitly given differently.
  • [[04_Pseudocode/Dry_Run_Method|Dry-run method]]
  • [[04_Pseudocode/Pseudocode_Patterns|Patterns and traps]]
  • [[04_Pseudocode/Pseudocode_Drills|Pseudocode drills]]

[[00_Start_Here/Dashboard|Back to dashboard]]