2.1 Algorithms Flashcards
What is an algorithm?
A sequence of step-by-step instructions to solve a problem or carry out a task. Can be represented using a flowchart or pseudocode.
What is a program?
A sequence of instructions for a computer.
What is computational thinking?
Solving problems logically, in a way that can be understood by humans and computers.
What is abstraction?
The removal of unwanted or unnecessary information from a task or problem in order to focus on the important and relevant information.
What is decomposition?
The process of breaking larger problem down into smaller tasks into smaller tasks that are easier to understand and solve.
What is sequence?
Carrying out tasks in a step-by-step series
What is iteration?
Repeating a task until a certain condition is met
What is selection?
A decision that needs to be made before the next step can be carried out.
What is a binary search?
Compares the required item to middle of the list, discards the irrelevant half of the list, repeats until the required item is found or the list has been fully checked.
Advantages and Disadvantages of binary search
+ Fast/efficient
- Only works in an ordered list
- Only works with numbers
What is a linear search?
compares each value in a list, one at a time, to a required value until a match is made.
Advantages and Disadvantages of linear search
+ Works with an unordered list
- Slower/less efficient than other searching algorithms
What is a bubble sort?
Repeatedly compares adjacent pairs of values in a list and swaps until all items are in order.
Advantages and Disadvantages of bubble sort
+ Simple algorithm and can be easily implemented on a computer
+ Doesn’t use much memory
- Doesn’t cope well with large lists
- Slower/less efficient than merge sort
What is a merge sort?
Data is repeatedly split into halves until single items remain, and is then reassembled in order.
Advantages and Disadvantages of merge sort
+ Quick/efficient
- It’s slower on algorithms for small lists
- Uses more memory than other sorting algorithms
What is an insertion sort?
Sorts data one element at a time. The algorithm takes one data from the list and places it in the correct location in the list. This process o=is repeated until there are no more unsorted items in the list.
Advantages and Disadvantages of insertion sort
+ Doesn’t use much memory
- Doesn’t cope well with large lists
Pseudocode
A shared programming language using simple English terms to plan programs
Flowcharts
Visualises an algorithm and shows clearly the flow of information
Advantages of flowcharts
- It is easy to see how a program flows. For example, where does following one path as opposed to another take the program?
- Flow diagrams follow an international standard - it’s easy for any flow diagram user to pick up a diagram and understand it.
Disadvantages of flowcharts
- with a large program, the diagrams can become huge in size and unwieldy to follow
- any changes to the design may mean a lot of the diagram has to be redrawn