Algorithms Flashcards
What is an algorithm?
A set of instructions used to solve a problem
How can algorithms be represented?
Using pseudocode or flowcharts
What are the symbols used in flow diagrams and what are their functions?
Line - Flow from one component to the next
Rectangle - Process
Parallelogram - Input/ Output
Rhombus - Decision
Oval -Start/Stop
*Rectangle w/ lines - Subroutine
What are the symbols used in flow diagrams and what are their functions?
Line - Flow from one component to the next
Rectangle - Process
Parallelogram - Input/ Output
Rhombus - Decision
Oval -Start/Stop
*Rectangle w/ lines - Subroutine
What is decomposition?
The breakdown of large problems into smaller , more manageable chunks
What is abstraction?
The removal of unnecessary details in a problem
Name 2 searching algorithms:
Linear search and Binary search
Describe how linear search works:
The algorithms starts at the beginning term of a list.
It the compares it to the value that is being searched, if the value matches, the algorithm stops as the value is found.
If not, it goes to the next term of that list and repeats the process.
This is repeated until either the value is found, or the end of the list has been reached, thus the value is not in the list.
Describe how binary search works:
Compare the searched value with the middle term in an ordered list.
If the values don’t match, split the list in half, if the searched value is smaller than the middle term, get rid of the bigger half, if it’s bigger, get rid of the smaller half.
Then, compare with the middle value of the new list, and repeat the process until the value is found
Compare binary and linear search:
- Binary search is more efficient for longer lists
- Linear search is simpler and better for shorter lists
3.Linear search can be used for unordered lists
Name 2 sorting algorithms:
Bubble sort and Merge sort
Describe how bubble sort works:
The algorithm starts with the first value in a list, it is compared to the second value - if the first value is bigger a swap is preformed, if not, they remain in that order.
The second value is then compared to the third value and the same process is performed.
This is done continuously until the end of the list is reached - one pass is done.
If the list is still not ordered the algorithm continues the process, until it is finally sorted
If the end of the list is reached with no swaps being made, the list is sorted