10 - Algorithms 3 (Search) Flashcards
What is searching?
Searching for an item in a collection
Why may you want to search?
Want to know if an item is there at all
Want to know an item’s position
Name 3 applications of searching
Parsing strings
Database queries
Finding files on a disk
What is linear searching?
Going through all items and checking if any equal the key
What’s the worse case of linear searching?
Going through all elements
What is the work and step complexity of linear search?
O(n)
What does the performance of linear search depend on?
The data distribution
What do databases and other applications use to accelerate searching?
Sorted lists or B-trees
What is binary search?
A divide and conquer searching technique
What is the process of binary searching?
Recursively/iteratively check if the middle location contains the key, if not then discard one half which cannot contain the value, check the middle location of the remaining half and so on
What is the parallel search input split?
Divide input into p parts (number of processing elements) and run a serial search for each part
What are the effects of the input split?
A potential speed up of p times
But need to wait for all threads to finish
Some threads might need to perform the worst case scenario
Latency corresponding to the slowest search
What is the parallel search multiple keys?
Perform multiple searches at the same time
What are the effects of multiple keys searching?
A potential speed up of p times
Underutilisation if a number of searches is smaller than p - lots of idle threads
Early exit
Larger p makes it more likely that the worst case execution time will happen
How does a parallel binary search benefit from parallelism?
Parallel implementation using p PEs can perform p searches simultaneously