- What is an algorithm?
- An algorithm is a solution to a problem expressed as a sequence of defined steps. Every algorithm is built from three constructs: sequence, selection and iteration. The data a problem uses is held under suitable identifier names, recorded in an identifier table.
- What is the difference between a pre-condition loop and a post-condition loop?
- A pre-condition loop tests before each pass, and a post-condition loop tests after each pass. A pre-condition loop is written as WHILE, and a post-condition loop is written as REPEAT ... UNTIL. Name a loop by where its test sits.
- How do I find the largest value in an array in pseudocode?
- Set Max to the first value input, then loop through the rest of the values. Inside the loop, IF Value > Max THEN Max ← Value ENDIF keeps the largest value found so far. After the loop, OUTPUT Max. The loop should repeat a stated number of times, using the loop counter as the array index.
- How do I draw a flowchart for a loop?
- A test is a decision diamond with two branches labelled True and False. A loop is drawn as an arrow back to the decision, with its counter set before the loop and changed inside it, in a separate box. A loop is never written as one box, such as repeat while Index < 51.
- How do I describe an algorithm in structured English without pseudocode?
- Write numbered plain-language steps, with no pseudocode statements. Name each variable and initialise it, and give the number of iterations of any loop, such as a loop to repeat 200 times using the loop counter as the array index. Say what is compared with what.
- What mistake do students make when they set the maximum value in an algorithm?
- Do not set Max ← 0 before the loop. Set Max to the first value input instead. Setting Max to 0 is wrong when the range of values is not known, because the largest value may be smaller than 0 and then the output would be wrong.