Search Algorithms Jennifer Mosher Math 382
Explicitly Stored Databases • Bank account information • Electronic documents • Personnel data • Manufacturing databases • Financial databases • An example: Quickbooks.
Linear vs Binary Search • Binary Search • Linear Search • Goes through, at • Goes through an most, half of the average of half of array before it finds the array before it match. finds match. • More Efficient • Less Efficient • Array must be • Two Situations ordered • Three Situations
The Algorithms • {1, 2, 3, 4, 5} • {1, 2, 3, 4 ,5} • Key = 3 • Key = 3 • Key is compared to • Key is compared to 1, 2, 3… middle element 3. • Finds a match. • Key matches. • Returns index, in • Returns index, again this case 2. 2.
• {1, 2, 3 , 4, 5} • Key = 7 • {1, 2, 3, 4, 5} • Key is compared to • Key = 7 middle element, 3. • Key is compared to • Doesn’t match. 1, 2, 3, 4, 5. • 7 > 3 • Searches second half • The search does not of array. find a match. • Key compared to 4 • Returns -1. and 5. • The search is • No match, returns -(insertion point + 1) = finished. -(5 + 1) = -6
Binary Search Tree • Binary Search Tree uses nodes • Four Situations
Virtual Search Spaces, Heuristics and Metaheuristics • Used to solve discrete optimization problems • Approximate • Good solutions in short amount of time • Usually not optimal solution
The Tabu Search • Created by Fred Glover, 1986 • Metaheuristic • Tabu lists – Short term memory of search – Tabus • Disallows moves that would undo prior moves • Sometimes too powerful – Aspiration Criteria
Termination of Tabu Search • Most popular ways: – After a fixed number of iterations – After some number of iterations without improvement in the objective function value – When an object reaches a pre-specified threshold value
Simulated Annealing • “Annealing”: – Process of heating and then cooling something repeatedly for softening and making material less brittle. • Traveling Salesman Problem • Tricks: – Allows Bad Trades – Lowering the temperature • Used for solving Sudoku
Constraint Propagation • Constraint Satisfaction Problems (CSP) • Infers that certain values cannot be part of certain variable domains because they violate some constraint. • An Example: – Constraint: y - 2x, 1 < x < 2 – Conclusion: 2 < y < 4 – In other words, y cannot be less than or equal to 2, or greater than or equal to 4.
Combinatorial Search • Used for CSP-like problems • Finds combinations of a discrete set of items that satisfy certain constraints • Combinatorial Optimization: – Finds a combination that maximizes or minimizes some parameter. • Drawback: solution time can grow exponentially with the problem size.
Quantum Computers • Today’s computers are limited to two states: a 0 or a 1. • Quantum computer is not. – 0, 1, or superposition of 0 and 1. • In other words the symbols are both 0 and 1 and all points in between at the same time.
Grover’s Algorithm • Invented in 1996 by Lov Grover • Poses following problem: – There is an unsorted database containing N items out of which just one item satisfies a given condition-- than item has to be retrieved. There does not exist any sorting on the database that would aid its selection. • Only other way is the Linear Search, which would use O(N) steps. • Grover’s Algorithm would use O(Sqrt(N)) • It is a quicker version of the linear search.
The Importance of Search Algorithms • Integral part of new technology age of the world. • Google.com, youTube, spell check, searching for a song in iTunes, and more.
Recommend
More recommend