Search algorithms form an integral part of many programs. Some searches may involve looking for an entry
Question:
Search algorithms form an integral part of many programs. Some searches may involve looking for an entry or a record in a database while other search algorithms may trawl through a virtual space, such as those hunting for the best chess moves. Although programmers can choose from numerous search types, they select the algorithm that best matches the size and structure of the database to provide a user-friendly experience.
Generally, searching problem can be described as looking for a particular element from a list of distinct elements or ascertain that the element is not in the list. An effective way of searching an element from these distinct set of elements is by making sure the elements are sorted either ascending or descending. This orders the elements of the list in a specified order just like the way names in a telephone directory are arranged in an alphabetical order. Now suppose you have been given a list of 8 integers say [1, 4, 5, 7, 12, 9, 16, 15] and you are to find the value 9 from the list.
i. Which of searching methods will be most suitable and why?
ii. State and explain the best and worst case search scenarios with respect to the list of 8 integers given.
iii. Adopt a suitable sorting algorithm to sort the elements in the list in an ascending order.
iv. Which searching method will be most appropriate for the sorted list and why? Apply the search method to find the value 12 from the list.
v. State Two (2) different ideas that has led to the promulgation of searching and sorting algorithms.