Unit 6
Unit 6
Introduction
Searching refers to an operation of finding the location of an item in a table or a file. Depending
on the location of the records to be searched, searching techniques are classified into two types.
External searching:
When the records are stored in files, disk, tape any secondary storage, then the searching is
known as external searching.
Internal searching
When the records to be searched are stored entirely within computer memory, then it is known as
internal searching.
Sorting is a method of arranging keys in a file in ascending or descending order. Sorting makes
handling of records in a file easier.
Prepared by : M V B REDDY 69
Some sorting techniques are
Bubble sort
Insertion sort
Selection sort
Quick sort
Tree sort
Linear search :
This is a simplest search technique. In this method, the array is searched for the required element
from the first element onwards either the list is exhausted or the required element is found.
Binary search :
To implement binary search method, the elements must be in sorted order. This method is
implemented as given below:
The key is compared with item in the middle position of array.
If the key matches with item, return it and stop.
If the key is less than mid positioned item, then the item to be found must be in first half of
array, otherwise it must be in second half of array.
Repeat the procedure for lower half (or upper half) of array until the elements is found.
Prepared by : M V B REDDY 70
QUIZ QUESTIONS
Prepared by : M V B REDDY 71
15. Insertion sort is implemented efficiently using
a) arrays b) linked list c) none
16. Data movement is minimized in
a) insertion sort b) selection sort c) both a & b d) none
Prepared by : M V B REDDY 72
PREVIOUS QUESTIONS
Prepared by : M V B REDDY 73