Skip to main content

Posts

Showing posts with the label Searching Algoritm

A review on Searching Algorithms

Philnits sure is useful. The review reminded me of Searching 101 from which I only remember the Linear Search algorithm. Linear search is a method of searching in sequential order. Given the following values: A = {4, 20, 31, 50, 23, 11, 30} index 1 2 3 4 5 6 7 Searching is performed in sequential order which means if we are looking for the number 50, we start comparing it from values of index 1 until we reach the search item. Another sorting algorithm is the Binary Search which is very useful when the elements are already sorted. Given the following values: A = {1, 12, 30, 34 ,50 ,56, 67, 78, 89} index 1 2 3 4 5 6 7 8 9 We would like to look for the number 67, We first get the median value: M = (1+9)/2 = 5 A[5] = 50 We disregard the lower half because 50 The lower bound now becomes M+1. L = M+1 = 5 +1 = 6 The new medi...