Searching Flashcards
1
Q
which is faster and why
A
binary as it needs to make less comparison
1
Q
what are the 2 ways to search a list?
A
binary
linear
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
3
Q
what type of list does binary need
A
ordered
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