Section 2 Chapter 9 - Writing and Interpreting Diagrams Flashcards
Properties of a good algorithm (5)
- Clear and precisely stated steps that produce a correct output
- Should allow for invalid inputs
- Must always terminate at some point
- Execute efficiently in as few steps as possible
- It should be designed in a way that is understandable and can be easily modifed
Common types of algorithm (4)
- Internet related
- Route finding
- Compression
- Encryption
Internet related algorithm
Can be used to manage and manipulate huge amounts of data stored on the Internet e.g. a search engine
Route finding algorithm
Finds the shortest route between two points for instance the fastest driving route or the best route to transmit packets over a network
Compression algorithm
Used to reduce the file space taken up by a file while still ideally retaining most of the relevant information
Encryption algorithm
Hides information so that it can only be read by the sender and receiver and not a third party
Binary search algorithm
1 - Check the value in the middle
2 - If larger than target, delete the second half of the list, if smaller delete the first half of the list
3 - Repeat steps 1 and 2 until the target is found
Sorting algorithm
Puts an unordered list in order
Bubble sort algorithm
1 - Loop through the array swapping each pair of values that are in the wrong order
2 - Repeat (length of list) time, reducing the number of elements to be examined by 1 each time
Tips for interpreting algorithms (4)
- Read the comments
- Look at the variable names
- Follow the steps in the program
- Try a “dry run” with some test data