KEMBAR78
Binary Search | PDF | Algorithms | Algorithms And Data Structures
0% found this document useful (0 votes)
22 views10 pages

Binary Search

Binary search pdf

Uploaded by

kimmrs205
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)
22 views10 pages

Binary Search

Binary search pdf

Uploaded by

kimmrs205
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/ 10

Binary search

What is Binary Search ?

Binary search is a fundamental


algorithm used to efficiently locate a
target value within a sorted array or
list.

By repeatedly dividing the search interval


in half, it quickly narrows down the
possible locations of the target, making it
significantly faster than linear search for
large datasets.
In binary search, the "divide and conquer" strategy is employed to efficiently
locate a target value within a sorted array. The approach involves repeatedly
The Power of Divide and Conquer dividing the array into smaller subarrays and focusing on the portion where
the target might be located. Initially, the array is divided into two halves, and
the middle element is compared with the target. Based on this
comparison, the search space is further reduced by selecting the
appropriate subarray for the next iteration. This process continues recursively
until either the target is found or the search space is exhausted. By dividing
the problem into smaller, manageable subproblems and conquering
them individually, binary search achieves logarithmic time complexity,
making it a highly efficient algorithm for searching in sorted datasets.
1. Set the lower bound (start) and upper bound (end)
of the search range. Algorithm for Binary Search:
2. Calculate the middle index.
3.Compare the target value with
the middle element.
4. If the target is smaller, adjust the upper bound.
5. If the target is larger, adjust the lower bound.
6.Repeat until the target is found or the bounds overlap.
PROS AND CONS
Pros Cons
- Efficient for sorted arrays - Requires sorted data
- Fast with logarithmic time
complexity -Additional memory overhead for
maintaining sorted data
- Relatively simple to implement
- Not suitable for dynamic
- Applicable to a wide range of datasets
problems
PROS AND CONS
Pros Cons
- Efficient for sorted arrays - Requires sorted data
- Fast with logarithmic time
complexity -Additional memory overhead for
maintaining sorted data
- Relatively simple to implement
- Not suitable for dynamic
- Applicable to a wide range of datasets
problems
Binary Search in Real World

Discover the real-world applications


of binary search in fields such as data
science, finance,and computer science.
THANK YOU!
Do you have any questions?
We are here to answer all your
doubts...

You might also like