Sorting and searching Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Explain the function of the linear search technique

A

It traverses the entire array and compares each value with the search value. If a match is found it returns the index or an approprate message

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

Explain the function of the binary search technique

A

Array must be first sorted.
The binary search then finds the midpoint of the indexes and compares it with the search value. If the search value is a match it will return that index. If the value is higher then low = mid+1 and if the value is lower high = mid -1 these processes will be repeated until the value is found or until low is greater than high

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