0% found this document useful (0 votes)
19 views14 pages

CIA3

Uploaded by

nepig34947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views14 pages

CIA3

Uploaded by

nepig34947
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

School Name : School of Engineering and Technology

Course Name : Data Structures

Group Members : Hitesh Milind Mahajan(200105231008),


Rupesh Dharmendra Jha(200105231011), Nitin Abhishek
Mishra(200105231004)

Name of the Topic : Searching Algorithms


1
Searching
Algorithms

Searching Algorithms are designed to check for


an element or retrieve an element from any
data structure where it is stored.

Based on the type of search operation, these


algorithms are generally classified into two
categories.
2
Searching Algorithms

Sequential Interval
Search Search

Linear Binary
Search Search

3
Sequential
Search

In this, the list or array is traversed


sequentially and every element is checked.

For example:-
Linear Search

4
Interval Search
These algorithms are specifically designed for
searching in sorted data-structures.
These type of searching algorithms are much
more efficient than Linear Search as they
repeatedly target the center of the search
structure and divide the search space in half.
For Example:-
Binary Search

5
Linear Search
Linear search is the simplest search
algorithm and often called sequential search.
In this type of searching, we simply traverse
the list completely and match each element of
the list with the item whose location is to be
found.
If the match found then location of the item is
returned otherwise the algorithm return
NULL.
Linear search is mostly used to search an
unordered list in which the items are not
sorted. 6
Steps for Linear Search

Step 1 - Read the search element from the


user.

Step 2 - Compare the search element with


the first element in the list.

Step 3 - If both are matched, then display


"Given element is found!!!" and terminate the
function.
7
Step 4 - If both are not matched, then
compare search element with the next
element in the list.

Step 5 - Repeat steps 3 and 4 until search


element is compared with last element in the
list.

Step 6 - If last element in the list also doesn't


match, then display "Element is not found!!!"
and terminate the function.
8
9
10
Binary Search
This search algorithm works on the principle
of divide and conquer.
For this algorithm to work properly, the data
collection should be in the sorted form.
Binary search looks for a particular item by
comparing the middle most item of the
collection.
If a match occurs, then the index of item is
returned. If the middle item is greater than
the item, then the item is searched in the sub-
array to the left of the middle item.
11
Otherwise, the item is searched for in the
sub-array to the right of the middle item. This
process continues on the sub-array as well
until the size of the subarray reduces to zero.

For a binary search to work, it is mandatory


for the target array to be sorted.

It is important to determine the half of the


array, which is calculated by using the
formula:-

mid = (low + high) / 2


12
13
Thank You

14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy