0% found this document useful (0 votes)
7 views7 pages

Arrays "Binary Search"

Uploaded by

anaghau777
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)
7 views7 pages

Arrays "Binary Search"

Uploaded by

anaghau777
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/ 7

Arrays

“Binary search”
Thrayee ,Anagha

11:11PM
enda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agenda • Agen

Topics Covered

Introduction Algorithm

Agenda
Example
Members and
their roles
Thrayee - Introduction ,
Example

Anagha - Algorithm

Back to Agenda Page


nary search • Binary search • Binary search • Binary search • Binary search • Binary search • Binary search • Section Heade

INTRODUCTION
Binary search is a fundamental algorithm used to locate a specific element in
a sorted list or array. It operates by repeatedly dividing the search range in
half, which makes it highly efficient compared to linear search, especially for
large datasets. By comparing the target value with the middle element of
the current range, the algorithm eliminates half of the remaining possibilities
in each step. This structured approach ensures a logarithmic time
complexity, making binary search an indispensable tool for solving problems
that require fast and accurate data retrieval.
Back to Agenda Page

ection Header • Section Header • Section Header • Section Header • Section Header • Section Header • Section Header • Sectio
Header
Search • Binary Search • Binary Search • Binary Search • Binary Search • Section Header • Section Header • Section Header

ALGORITHM
Step 1: the elements in the array ar[] having n elements in sorted order.
Step 2: Input the elements to e searched, ns.
Step 3: Ib=0, ub=n-1, m=0, k=0.
Step 4: while(Ib<=ub) and k=0 repeat steps 5 to 7
Step 5: m=(Ib+ub)/2
Step 6: if(ns==ar[m]) then k=1
Step 7: if(ns<ar[m]) then ub=m-1, else Ib=m+1
Step 8: if k=1 then print “Search succesful” else print “Search unseccesful”.
Step 9: End

n Header • Section Header • Section Header • Section Header • Section Header • Section Header • Section Header • Section H
nary Search • Binary Search • Binary Search • Binary Search • Binary Search • Binary Search • Binary Searchr • Binary Sear

EXAMPLE
Imagine you are trying to find the phone number of "Sowmya" in a thick
phone book where names are listed alphabetically

You start by flipping to the middle of the book.


If the name in the middle is "John" you know "Sowmya" would be later in the book
because "Sowmya" comes after "John" alphabetically.
You ignore the entire first half of the book because "Sowmya" cannot be there.
Focus only on the second half.
Flip to the middle of the second half.
If the name in the middle is "Thrayee," you know "Sowmya" is earlier in this half since
"Sowmya" comes before "Thrayee."
Back to Agenda Page
Keep narrowing down by halving the search area until you find "Sowmya."

n Header • Section Header • Section Header • Section Header • Section Header • Section Header • Section Header • Section H
Thank you!

You might also like