Sentinel search or Sentinel Linear search is modified version of Linear search.Here the idea is to reduce the total number of comparison required to find element. This algorithm replace the last element of the array with the search element itself and run loop without checking index range of array because the element to be searched will definitely found at last position of array if search element is found then loop is terminated.
Program:
while loop is used because sentinel search does not require to check index range of array.
Program:
while loop is used because sentinel search does not require to check index range of array.
Output:
No comments:
Post a Comment