1 - Fundamentals of Algorithms Flashcards
Not to screw up
What is an algorithm
A series of instructions that describes how to solve a specific problem or perform a specific task
What is decomposition
Breaking down a problem down into smaller ‘sub-problems’
Advantages of decomposition
- Smaller problems are easier to solve than larger problems
- Each ‘sub-problem’ can be developed separately, making planning and working to a timescale easier
- ‘Sub-problems’ are easier to distribute among a team than one large problem
Inputs, Initialisation, processing, outputs
Inputs - what data enters the system and how?
Initialisation - What variables are needed and what are their initial values?
Processing - What processes (calculations, sorts, etc.) are carried out on the inputs?
Outputs - What data leaves the system and in what format?
Abstraction
Hiding the layers of complexity within a system, in order to focus on one specific layer of complexity
Common methods of defining algorithms
- Pseudocode
- Flowcharts
Pseudocode
A cross between English and a generic-looking programming language. While pseudocode would not compile, a competent programmer could convert it to code that would compile
Flow Chart
A means of defining an algorithm using shapes and arrows. Within each shape, an action is taking place or a decision is being made. The direction of arrows indicates which action or decision comes next
Flow charts are easier understood than pseudocode to someone who is not a programmer
Oval
This is the terminator. One is used to mark the start and another is used to mark the end. They are not used elsewhere
Arrow
Shows which instruction should take place next
Diamond
A decision. It asks a question and each arrow leaving must have a possible answer
Square/ rectangle
This is a process. Each one contains a single instruction. so complex tasks usually incorporate several processes
Parallelogram
This shape represents data that is entered into the system or output from it. Basically input or output
Sequence
A sequence is when instructions in an algorithm each need to be executed only once, and in the order in which they are written
Selection
Selection is when one sequence of instructions or another, but not both, is executed. The sequence that is executed will depend on what happened in earlier instructions.