Algorithms Flashcards
(10 cards)
What is an algorithm
An algorithm is a list of rules to follow in order to solve a problem. Algorithms need to have their steps in the right order. When you write an algorithm the order of the instructions is very important. A computer uses an algorithm to complete tasks.
How do algorithms and computer programs relate?
A computer program is an implementation of an algorithm
What shape is used to show an input/output in flowchart?
parallelogram
What shape is used to show a process in flowchart?
a rectangle
What shape is used to show a decision in flowchart?
a diamond
What is a linear search?
A linear search is an algorithm that checks all whole list until it finds what it is searching for or until it searches the whole list.
What does a list need to be for you to be able to binary search it?
in numerical order
How does a binary search work?
A binary search works by finding the middle number in the ordered list and checking if its what its searching for. If it isn’t the computer checks if the search number is bigger than the middle number or not and then it discards the half of the list that the number isn’t in. It keeps doing this until it finds the number or it checks the whole list.
merge sort 42 31 12 3 37 18 29 47
42 31 12 3 37 18 29 47
31 42 3 12 18 37 29 47
3 12 31 42 18 29 37 47
3 12 18 29 31 37 42 47
Bubble sort 9 5 4 15 3 8 11 2
5 9 4 15 3 8 11 2 5 4 9 15 3 8 11 2 5 4 9 3 15 8 11 2 5 4 9 3 8 15 11 2 5 4 9 3 8 11 15 2 5 4 9 3 8 11 2 15 4 5 3 8 9 2 11 15 4 3 5 8 2 9 11 15 3 4 2 5 8 9 11 15 3 2 4 5 8 9 11 15 2 3 4 5 8 9 11 15