Programming Concepts and Algorithms
Programming Concepts and Algorithms
This domain tests problem decomposition, algorithm representation, control structures, arrays, and basic searching/sorting. Expect pseudocode or flowchart reasoning rather than language-specific syntax.
Core rules
- An algorithm is a finite, ordered, unambiguous set of steps. A flowchart uses oval for start/end, parallelogram for input/output, rectangle for process, diamond for decision.
- Three control structures: sequence, selection (
if/else,switch) and iteration (while,for,do-while). - A variable is a named storage location; assignment stores a value, while comparison tests it.
- Arrays store multiple values of one type under one name, accessed by index.
- Linear search checks items in order; binary search requires sorted data and halves the search space.
Worked example
Algorithm to sum 1 to n: input n; set sum=0; set i=1; while i<=n, add i to sum and increment i; output sum. For n=4: i=1 sum=1; i=2 sum=3; i=3 sum=6; i=4 sum=10; i=5 stops. The reasoning is loop invariant: after each pass, sum is the total of values processed so far.
Traps
Using = for comparison in pseudocode can confuse assignment and equality. A loop that never changes its control variable is infinite. Off-by-one errors occur at <= versus <. Binary search on unsorted data is invalid. A flowchart decision has two outgoing branches, not one.