click below
click below
Normal Size Small Size show me how
Algorithms
2.1
Term | Definition | Advantages | Disadvantages |
---|---|---|---|
Abstraction | simplifies a problem by removing unnecessary detail so that you can focus on the important parts that are relevant to the problem | ||
Decomposition | breaking a complex problem into smaller, more manageable sub-problems | allows large teams to each take a part of a problem and work on it. allows seemingly impossible problems to be solved by splitting them into simple tasks. | |
Structure charts | visually represents breaking a large problem down into the smaller parts that make it up Each box represents a smaller problem to be solved Lines show which bigger problem the box is a part of | ||
Algorithmic Thinking | solving problems by producing algorithms - a reusable set of instructions to solve a given problem | ||
Pseudocode | a way to write out algorithms using code-like statements | very readable, and easy to understand | |
Flow diagrams | visually represents the steps that make up an algorithm | ||
Rules of flow diagrams | Arrows - the flow of control, or what to execute next Oval - start and end Rectangle - a process Parallelogram - input or output Diamond - decision | ||
Things to look out for when interpreting flow diagrams | Identifiers - names of variables, constants, and subroutines Inputs and outputs Output messages Comments | ||
Correcting algorithms | Missing processes Incorrect identifiers Incorrect operators | ||
Completing algorithms | Interpreting the algorithm Truce table | ||
Search algorithms | a set of instructions for finding a specific item of data within a data set | ||
Effective searching | one which will always either find the solution or determine that the target data is not present | ||
Efficient searching | finds the solution quickly regardless of its location within the data set | ||
Linear search | To check each item in a list individually to check if its the one you want | easy to implement | Slow on a long list |
Binary search | Divide and conquer - to divide the list in half, checking if the item is in that half. This process is repeated until there are no divisions possible. | Faster than linear search on a large dataset | Dataset must be sorted |
Sort algorithms | a set of instructions to arrange a dataset into a particular order | ||
Bubble sort | Compare the first two items, swapping them if needed Repeat process for the rest of the cards Repeat process until sorted | Easy to implement Little memory used | Poor efficiency |
Insertion sort | Take the second card, compare and swap with the first if needed Take the third card, compare with the second and first, making any swaps if needed Repeat for all cards | Easy to implement Little memory used | Poor efficiency |
merge sort | Divide and conquer - Split the lists into lists of size one Merge each pair of sublists by comparing the first value of each list and putting the smaller value into the new list first Continue merging until there is only one list | Very efficient | Can be slower for small lists Needs additional memory |