0% found this document useful (0 votes)
3 views17 pages

Presentation Searching Algorithms

The document provides an overview of searching algorithms, focusing on Linear Search and Binary Search. Linear Search is simple and works on unsorted data but is slow for large datasets, while Binary Search is efficient for sorted data. Real-life applications include e-commerce, navigation, and data analysis, emphasizing the importance of choosing the right algorithm for optimal performance.

Uploaded by

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

Presentation Searching Algorithms

The document provides an overview of searching algorithms, focusing on Linear Search and Binary Search. Linear Search is simple and works on unsorted data but is slow for large datasets, while Binary Search is efficient for sorted data. Real-life applications include e-commerce, navigation, and data analysis, emphasizing the importance of choosing the right algorithm for optimal performance.

Uploaded by

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

Searching

Algorithms

Present By Taem United 3.0


Meet with team
UNITED 3.O

Pranto Kumar Saha Md Farhan Tanvir


242-15-278 242-15-692
Eamin Hossain Md. Maruf Hasan Ahanaf Tahmid Taif
242-15-823 242-15-606 242-15-064
Introduction to
Searching Algorithms
A searching algorithm is used to find a specific element in a
dataset.
It helps locate data quickly and efficiently.
Commonly used in arrays, lists, and databases.
Plays a vital role in data processing, software, and real-life
applications.

Two basic types: Linear Search and Binary Search.


Real-Life Examples:

Contact Search in Mobile Phones


Navigation Systems (Google Maps)
File Search in Computers
Game AI
Library Management Systems
Product Search in E-commerce (Amazon, Daraz)
Searching for a movie title on Netflix.
Types of
Linear Search

Simple and straightforward search method

Algorithms ➤
Binary Search
Efficient search for sorted data
Understanding
Linear Search
Linear search finds an element by sequentially checking each
element in a list until the desired one is found.
Simple to Implement:
➤ Very easy to write and understand, even for

Linear
beginners.

Works on Unsorted Data:

Search Pros

No need to sort the data before searching.

Slow for Large Data Sets:

& Cons

As the list grows, the time to search increases
linearly.

No Performance Improvement on
➤ Sorted Data:
Even if the data is sorted, linear search doesn’t take
advantage of that.
Linear Search – Algorithm
Simulation
Pseudocode:

Consider the array and size=9


arr[] = {10, 50, 30, 70, 80, 60,20, 90, 40} for i=0
key = 30

for i = 0 to n-1:
if arr[i] == key:
return i;
for i=1
return -1

for i=2
Understanding
Binar y Search
One of the most efficient searching techniques in computer
science.
It helps us find elements in a sorted list much faster than
linear search.
Binary Search is an algorithm used to find the position of a
target element in a sorted array.
Instead of checking every element one by one, it keeps
dividing the search space in half, which makes it very fast.

Binary Search only works if:


The list is sorted
We can access elements using their index (like in arrays)
Here’s how Binary Search works:

Start with the middle element.

Binary If it's the target, we’re done.

Search
If the target is smaller, we search the left half.

If the target is bigger, we search the right half.

process
We keep repeating this process until we find
the element or the search space is empty.
Binary Search – Algorithm (Pseudocode)
Consider an array
arr[] = {2, 5, 8, 12, 16, 23, 38, 56, 72, 91}
target = 23
int binarySearch(int arr[], int low, int high, int key)
{
low =0;
high=n-1;
while (low <= high) {
int mid = (low + high ) / 2;

if (arr[mid] == key)
return mid;

if (arr[mid] < key)


low = mid + 1;

else
high = mid - 1;
}
return -1;
}
Real-life Applications of Searching
Algorithms

01 02 03
E-commerce Data Analysis Navigation

Efficient product searches Searching large datasets


enhance customer experience enables insightful decision Finding routes quickly helps in
and sales. making. time management.
Comparison of Searching Algorithms
Citeria Linear Search Binary Search

Data Requirement Unsorted Sorted Only

Time Complexity O(n) O(logn)

Space Complexity O( 1 ) O( 1 )

Speed Slow for large Data Fast for large Data

Best Case Small Large


When to Use
Which “Searching Algorithm?”

Scenario Use This Search

Small or unsorted dataset 🔍 Linear Search


Large and sorted dataset ⚡ Binary Search
For Index searching ✔️ Binary Search
Simpler code is needed ✅ Linear Search
“Conclusion”
Searching is used in real life and in computer programs.
Linear Search - is simple and works for small or unsorted lists.
Binary Search - is faster but needs a sorted list.

Using the right method makes our program faster and better.

In short: Better search = Better performance.


THANK YOU !!

You might also like