Searching is the process of determining whether or
not a given value exists in a data structure or a
linear search and binary search.
3. LINEAR SEARCH
The linear (or sequential) search algorithm on an
Sequentially scan the array, comparing each array item with the searched
If a match is found; return the index of the matched element; otherwise
Note: linear search can be applied to both sorted and
4. FEATURES OF LINEAR SEARCH
It is used for unsorted and unordered small list of
It has a time complexity of O(n), which means the
time is linearly dependent on the number of
elements, which is not bad, but not that good too.
It has a very simple implementation.
6. APPLICATIONS OF LINEAR SEARCH
Used to find the desired element from the collection
of data when the dataset is small
The searching operations is less than 100 items
7. BINARY SEARCH
An algorithm to solve this task looks at the
middle of the array or array segment first
If the value looked for is smaller than the
value in the middle of the array
Then the second half of the array or array
segment can be ignored
This strategy is then applied to the first half of the
array or array segment
8. BINARY SEARCH (CONT.,)
If the value looked for is larger than the value in the
middle of the array or array segment
Then the first half of the array or array segment can be
This strategy is then applied to the second half of the array
or array segment
If the value looked for is at the middle of the array
or array segment, then it has been found
If the entire array (or array segment) has been
searched in this way without finding the value, then
it is not in the array
9. EFFICIENCY OF BINARY SEARCH
The binary search algorithm is extremely fast
compared to an algorithm that tries all array
elements in order
About half the array is eliminated from consideration
right at the start
Then a quarter of the array, then an eighth of the array,
and so forth
11. APPLICATIONS OF BINARY SEARCH
The binary search algorithm is used in the libraries
of Java, C++, etc
It is used in another additional program like finding
the smallest element or largest element in the array
It is used to implement a dictionary
12. SORTING METHODS
Sorting Algorithms are methods of reorganizing a
large number of items into some specific order such
as highest to lowest, or vice-versa, or even in some
These algorithms take an input list, processes it
(i.e, performs some operations on it) and produce
the sorted list.
The most common example we experience every
day is sorting clothes or other items on an e-
commerce website either by lowest-price to highest,
or list by popularity, or some other order.
14. BUBBLE SORT
Bubble sort, also referred to as comparison sort
It is a simple sorting algorithm that repeatedly goes
through the list, compares adjacent elements and
swaps them if they are in the wrong order.
This is the most simplest algorithm and inefficient at
the same time.
15. SELECTION SORT
Selection sort is a simple comparison-based sorting
Steps to be followed
Pick the minimum element from the unsorted
Swap it with the leftmost element of the unsorted
Now the leftmost element of unsorted subarray
becomes a part (rightmost) of sorted subarray and
will not be a part of unsorted subarray.
16. INSERTION SORT
Insertion sort is the sorting mechanism where the
sorted array is built having one item at a time.
The array elements are compared with each other
sequentially and then arranged simultaneously in
some particular order.
This sort works on the principle of inserting an
element at a particular position, hence the name
17. SHELL SORT
Shell sort is a highly efficient sorting algorithm and is
based on insertion sort algorithm.
This algorithm avoids large shifts as in case of insertion
sort, if the smaller value is to the far right and has to be
moved to the far left.
Steps to be followed
Step 1 − Initialize the value of h.
Step 2 − Divide the list into smaller sub-list of equal
Step 3 − Sort these sub-lists using insertion sort.
Step 3 − Repeat until complete list is sorted.
18. RADIX SORT
Radix sort is one of the sorting algorithms used
to sort a list of integer numbers in order.
In radix sort algorithm, a list of integer numbers will
be sorted based on the digits of individual numbers.
Sorting is performed from least significant digit to
the most significant digit.
20. QUICK SORT
It is one of the most efficient sorting algorithms and
is based on the splitting of an array (partition) into
smaller ones and swapping (exchange) based on
the comparison with 'pivot' element selected.
Due to this, quick sort is also called as "Partition
Steps to be followed:
Step 1 − Make any element as pivot
Step 2 − Partition the array on the basis of pivot
Step 3 − Apply quick sort on left partition
Step 4 − Apply quick sort on right partition
22. HEAP SORT
Heap sort is a comparison-based sorting
technique based on Binary Heap data structure
There are two kinds of heaps: min-heap and max-
In min-heap parents nodes are smaller than
children nodes (the root node is smallest), while in
max-heap it is opposite (the root node is largest).
23. MERGE SORT
Merge sort is one of the most efficient sorting
algorithms. It works on the principle of Divide and
Merge sort repeatedly breaks down a list into
several sublists until each sublist consists of a
single element and merging those sublists in a
manner that results into a sorted list.
24. COMPARISON OF SORTING ALOGORITHMS
In a comparison based sorting algorithms, we
compare elements of an array with each other to
determines which of two elements should occur first
in the final sorted list.
All comparison-based sorting algorithms have a
complexity lower bound of nlogn.