Component 2.2 - Algorithms And Programming Constructs Flashcards
(36 cards)
What is an algorithm?
An algorithm is a set of instructions that can be used to solve a given problem
What two things must the instructions of an algorithm be?
- clear
- in the correct order to produce the solution
Algorithms are a ___ for writing a computer program to ___
Starting point, solve the given problem
What programming language should an algorithm be presented in?
Algorithms should be presented in a way that it can be used in different programming languages. It should NOT be in computer code
What is pseudo code?
Pseudo code is a way of writing instructions in plain english
What is a flowchart?
A flowchart is a diagram showing the instructions to be carried out in the order they should be carried out
What 3 things must a good algorithm be?
- Be finite - must not never end trying to solve a problem
- have well defined instruction (each step must be clear)
- be effective (it should give the correct result/solution)
What does a rounded rectangle mean in a flowchart?
Start/stop
What does a diamond mean in a flowchart?
Decision
What does a parallelogram mean in a flowchart?
Input/Output
What does a rectangle mean in a flowchart?
Operation
What does a circle mean in a flowchart?
Connector
What does a rectangle with two lines near each end mean in a flowchart?
Store/call subroutine
What are the three basic constructs used to design algorithms?
Sequence, selection and iteration
What is the sequence construct of an algorithm?
Algorithms consist of a series of instructions in a specific order. It is the sequence in which instructions must be carried out for the algorithm to work.
What happens if the sequence if an algorithm is not right?
Computers can only follow instructions in the order they are given, if the sequence is not right the computer will still follow the order they are given in
What is the selection construct of an algorithm?
A selection instruction is one where a decision must be made. This is the times in which an instruction in an algorithm may give different options
What is the iteration construct of an algorithm?
Sometimes an algorithm will need a series of steps to be carried out more than once. This is called iteration, often referred to as a loop in a program. (E.g. for next loop)
When will you use a loop with a count or rouge value?
You would use this when you do not know how many times you will need the instructions in the loop to be used
How does a count value loop work?
Count records the-number of times a process is carried out and when it reaches the required number the loop terminates
What is a rogue value?
A rogue value is a value that falls outside the range of possible values for the data that is being processed
How does a rogue galue loop work?
If there is a loop asking for inputs, storing them as var which must be positive, you could input -1 for var which will end the loop (following your code)
What does a sorting algorithm do?
A sorting algorithm will put items in a list into a particular order, alphabetic or numeric
What is merge sort?
Merge sort is a sorting technique based on the idea of ‘divide and conquer’