Please enable JavaScript.
Coggle requires JavaScript to display documents.
Searching Algorithms - Coggle Diagram
Searching Algorithms
Median
-
Calculating on paper
If the list is an odd numbered length then you find the number in the middle, if the number is even you pick either the middle number on the left or on the right
Calculating when coding, using the index position
Start index + end index DIV 2
Brute force algorithm
Keep trying until you find the answer, uses lots of computing power but no specialist techniques
-
-
Data set
Where you are looking - could be a list, a database, a file etc.
-
-
-
-
Binary search advantages
Less comparisons are needed, worst case scenario for 100 numbers = 6 comparisons
-
Best case scenario
Linear - the number you are searching for is the first item in the list - 1 comparison
Binary - the number is the first median you find in the list - 1 comparison
-
Worst case scenario
Linear - the number you are searching for is the last item in the list - comparison of all values
Binary - the number is the first or last item in the list - comparison of some values