Binary and Linear Search Flashcards
1
Q
What is a Linear Search and how does it work?
A
Finds an item unsorted and sorted lists, starts at first item in the line and checks each 1 by 1 effective for small data sets not large ones
2
Q
Pseudocode for Linear Search
A
Found = False Index = 0 While found == False and index < items. Lenth If items[index] == item_to_find then Found = True Else Index = Index + 1 End if End While
3
Q
What is Binary Search
A
Efficient algorithm finding item in sorted data set, starts in the middle and repeatedly divides itself in half best for large data sets