Algorithm Design and Problem-solving
Advanced algorithmic thinking and problem-solving strategies.
Topics
- Abstract Data Types
- Algorithm Efficiency
- Recursion
- Standard Algorithms
Key terms
9.1 Computational thinking
- Computational thinking
- Approaching a problem in ways a computer could help solve, using abstraction, decomposition, pattern recognition and algorithms.
- Abstraction
- Focusing on the essential details of a problem and hiding the irrelevant ones.
- Decomposition
- Breaking a complex problem into smaller, more manageable sub-problems.
- Pattern recognition
- Spotting similarities between problems so that a known solution can be reused.
- Algorithm
- A finite, ordered set of unambiguous steps that solves a problem.
- Top-down design
- Starting with the whole problem and breaking it into smaller and smaller sub-problems.
- Stepwise refinement
- Repeatedly breaking each step of an algorithm into more detailed steps until it can be coded.
- Modular design
- Splitting a solution into independent modules that each do one job.
9.2 Describing algorithms
- Structure diagram
- A hierarchy chart showing how a problem is broken into sub-tasks or modules.
- Flowchart
- A diagram that shows the steps of an algorithm using standard symbols joined by arrows.
- Terminator (oval) symbol
- Shows the start or end of a flowchart.
- Process (rectangle) symbol
- Shows a process, such as a calculation or assignment.
- Decision (diamond) symbol
- Shows a yes/no question, with one arrow out for each answer.
- Input/output (parallelogram) symbol
- Shows data being input or output.
- Subroutine call symbol
- A rectangle with double vertical bars, showing a call to a subroutine.
- Structured English
- Describing an algorithm in plain, constrained English using words such as IF, THEN and REPEAT.
- Pseudocode
- A language-independent way of writing an algorithm that looks like code but isn't tied to a real language.
- DECLARE
- Pseudocode keyword that creates a variable and sets its data type.
- Assignment (←)
- Stores a value in a variable, for example Total ← Total + 1.
- DIV and MOD
- DIV gives the whole-number part of a division. MOD gives the remainder.
- CASE OF ... OTHERWISE
- Selects one of several fixed options. OTHERWISE covers any value not listed.
- FOR ... NEXT loop
- A count-controlled loop that repeats a set number of times, optionally with a STEP.
- WHILE ... ENDWHILE loop
- A condition-controlled loop that tests its condition before each repetition.
- REPEAT ... UNTIL loop
- A condition-controlled loop that tests its condition at the end, so it always runs at least once.
9.3 Standard methods of solution
- Totalling
- Adding values to a running total as they are processed.
- Counting
- Adding 1 to a counter each time an item meets a condition.
- Finding the maximum or minimum
- Starting with the first value, then replacing it whenever a larger (or smaller) one is found.
- Average
- The total of the values divided by how many there are.
- Linear search
- Checking each item in turn until the target is found or the end of the list is reached.
- Binary search
- Repeatedly halving a sorted list by comparing the target with the middle item.
- Bubble sort
- Sorts by repeatedly comparing neighbouring items and swapping them if they are in the wrong order.
- Insertion sort
- Sorts by taking each item in turn and inserting it into its correct place in the already sorted part of the list.
- Efficiency
- How much time and memory an algorithm needs as the amount of data grows.
Practice questions for Algorithm Design and Problem-solving