Algorithms Flashcards

1
Q

What is an algorithm

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do algorithms and computer programs relate?

A

A computer program is an implementation of an algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What shape is used to show an input/output in flowchart?

A

parallelogram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What shape is used to show a process in flowchart?

A

a rectangle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What shape is used to show a decision in flowchart?

A

a diamond

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a linear search?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does a list need to be for you to be able to binary search it?

A

in numerical order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does a binary search work?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

merge sort 42 31 12 3 37 18 29 47

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Bubble sort 9 5 4 15 3 8 11 2

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly