Searching and Sorting Updated
Searching and Sorting Updated
Searching and Sorting Updated
no 6
Introduction to
Searching & Sorting
(7 Hour)
Module 6
Introduction to Sorting and Searching --------------07
Introduction to Searching: Linear search, Binary search,
Sorting: Internal VS. External Sorting, Sorting Techniques:
Bubble, Insertion, selection,
Quick Sort, Merge Sort, Comparison of sorting Techniques
based on their complexity.
Hashing Techniques, Different Hash functions, Collision &
Collision resolution
techniques: Linear and Quadratic probing, Double hashing.
SEARCHING
• Searching means to find whether a
particular value is present in an array or not.
If the value is present in the array, then
searching is said to be successful and the
searching process gives the location of
that value in the array.
• if the value is not present in the array, the
searching process displays an appropriate
message and in this case searching is said
to be unsuccessful.
• There are two popular methods for
searching the array elements:
1) linear search
2) binary search.
Linear Search
• Linear search, also called as sequential
search, is a very simple method used for
searching an array for a particular value. It
works by comparing the value to be
searched with every element of the array
one by one in a sequence until a match is
found.
• Linear search is mostly used to search
an unordered list of elements
int A[] = {15, 5, 20, 35, 2, 42, 67, 17};
In Steps 1 and 2 of the algorithm, we initialize the value
of POS and I. In Step 3, a while loop is executed that would
be executed till I is less than N (total number of elements
in the array).
and the value to be searched is VAL = 9. The algorithm will proceed in the
following manner.