Searching Flashcards

1
Q

which is faster and why

A

binary as it needs to make less comparison

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

what are the 2 ways to search a list?

A

binary
linear

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

how does linear search work

A

the algorithm will go through each number 1 by 1 and check if it is the correct number, this will keep happening until it reaches the right number

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

what type of list does binary need

A

ordered

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

how does binary search

A

go to the middle of the list and check if that is the number, if not check if the number is larger than or greater than the current number and discard the other part of the list. repeat this process until the number is found

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