2.1 Algorithms Flashcards
How can algorithms be written -
As flowcharts, pseudocode or python
Algorithms
a step-by-step set of instructions to solve a problem.
What is pseudocode?
Code written in English. The idea is that programmers can plan an algorithm before they actually start programming it.
Flowcharts -
Another way to design algorithms that all programmers will be able to understand and implement in their own programming language.
Linear search
Just looks through each item in the list until it finds it.
Binary search
Finds the middle value of the list. Breaks the list in two, sees if it is above or below the middle. If it is above, it will then discard the bottom half of the list. It will then break the top half in two. Again, it checks if it is above or below, if it is below, it will discard the top half and so on until it finds the item.
Bubble sort
Swaps values in to order with each iteration until they are in order.
Merge sort -
Breaks the lists into smaller lists and rearranges and merges them into the correct order.
Insertion sort -
Takes the list values out and inserts them into the correct order.
Abstraction -
Removing unnecessary details. Focusing only on the details you want.
Decomposition -
Breaking a problem down into smaller solvable sub-problems.
Algorithmic Thinking -
Creating step-by-step instructions to solve a problem using computers.
Syntax Errors -
Will cause an error. Your code will not run.
Logic Errors -
Will not cause an error. Your code will run, but not as intended.
Structure Diagrams -
Can be used to show how a program can be DECOMPOSED into separate SUB- ROUTINES.