CHAPTER 12

SEARCHING:  TO LOOK AND TO FIND  

The computer was invented to perform complex mathematical computations, however this trend has changed and the computer has become more of a searching machine (engine). Non-stop, this machine looks to find proper matches, travel destinations, inventories, personal files, or even previous computations. In fact, searching is the center of most computer applications and increasingly dominates all aspects of our home, school, and office applications.  Many algorithms have been developed to perform these searches, however, some searching algorithms are easy, some are difficult, and some are faster than others. Among the searching algorithms we can name sequential (linear) search, binary search and hashing.  Each of these searches has their own advantages and disadvantages. One can argue that, with the high speed and memory size of today’s computer, linear search would be sufficient for relatively small data sets. But, as the amount of data overwhelmingly increases, there is as need to explore alternative algorithms for searching.  Hashing performs best in certain situations in comparison to other searching algorithms. Another efficient searching algorithm is known as search tree built on a data structure called tree. The data on a tree is stored in a fashion representing the branches of a tree and a root, interestingly it should be viewed upside down. The tree-searching algorithm can be difficult to understand and program. Understanding and analyzing various searching techniques using criteria such as consumption of computer time and/or space enables one to choose and decide on a proper search technique. 

SEARCH PROGRAM STEPS

Every search program consists of the following three major steps.

1.      Interaction

2.      Look at existing information

3.      Responding back  

In the interaction step, the program asks the user to enter a proper request; and user responds by inputting the data, usually through the keyboard. In the second step, the program will take the requested information (search key) and search through existing information that is stored in a file, array, memory location, or any other data structures. The program then responds back to say whether or not the information was found.