0% found this document useful (0 votes)
10 views15 pages

PPS Present

Uploaded by

saivarun437
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)
10 views15 pages

PPS Present

Uploaded by

saivarun437
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/ 15

Searching in

PPS
Introduction to Searching

 • Searching is the process of finding location of


specific element in an data structure.
 • It is one of the fundamental operations in
problem-solving and programming.
 • Commonly used in databases, search engines,
and applications requiring quick access to data.
Types of Searching

 1. Linear Search:
 - Sequentially checks each element until the
target is found or the list ends.
 - Time Complexity: O(n)

 2. Binary Search:
 - Works on sorted data by dividing the search
space into halves.
 - Time Complexity: O(log n)
Linear vs Binary Search

 Linear Search:
 • Better for unsorted data
 • Time Complexity: O(n)
 • Easy to implement
 • Simple and easy method.

 Binary Search:
 • Requires sorted data
 • Time Complexity: O(log n)
 • More efficient for large datasets
Applications of Searching

 • Database Management Systems


 • Search Engines
 • E-commerce platforms (finding products)
 • Navigation Systems
 • Cybersecurity (pattern matching)
How Linear Search Works

 1. Start at the first element.


 2. Compare the target with the current element.
 3. If a match is found, return the index.
 4. If no match is found, move to the next element.
 5. Repeat until the end of the list.
How Binary Search Works

 1. Start with the middle element of the sorted list.


 2. Compare the target with the middle element.
 3. If it matches, return the index.
 4. If the target is smaller, search the left half.
 5. If the target is larger, search the right half.
 6. Repeat until the target is found or the search space is empty.
Advantages and
Disadvantages: Linear Search

 Advantages:
 • Simple to implement.
 • Works on both sorted and unsorted data.

 Disadvantages:
 • Inefficient for large datasets.
 • Time complexity: O(n), which can be slow for
larger inputs.
Advantages and
Disadvantages: Binary Search

 Advantages:
 • Highly efficient for large, sorted datasets.
 • Time complexity: O(log n).

 Disadvantages:
 • Only works on sorted data.
 • Requires additional sorting if the data isn't
sorted.
Real-life Examples of
Searching
 1. Searching for a contact in a phonebook (Binary
Search).
 2. Looking up a word in a dictionary (Binary
Search).
 3. Finding a product on an e-commerce site
(Search algorithms).
 4. Searching for files or folders on a computer (File
system search).
 5. Pattern matching in text or DNA sequences.
Time and Space
Complexities
 Linear Search:
 • Time Complexity: O(n)
 • Space Complexity: O(1)

 Binary Search:
 • Time Complexity: O(log n)
 • Space Complexity: O(1) (iterative) or O(log n)
(recursive).
Use Cases for Searching
Methods
 • Linear Search:
 - Useful for small datasets.
 - Works well when data is not sorted.

 • Binary Search:
 - Preferred for large datasets that are sorted.
 - Often used in databases and search engines.
Searching in
Multidimensional Data
 • Searching in 2D Arrays:
 - Linear search can traverse row by row.
 - Binary search can be applied if rows and
columns are sorted.

 • Applications:
 - Image processing.
 - Geographic Information Systems (GIS).
Advanced Searching
Algorithms
 • Hashing:
 - Uses a hash table for constant-time search.

 • Interpolation Search:
 - Works on sorted and uniformly distributed data.
 - Time Complexity: O(log(log n)).

 • Exponential Search:
 - Efficient for unbounded lists.
THANK YOU
PRESENTATION BY
24241A6735 - N.Vedavyas
24241A6737 - P.Nikhil Yadav
24241A6750 - S.Hemanth
24241A6751 - S.Varun
24241A6762 - V.Sai varun

You might also like