0% found this document useful (0 votes)
18 views

Binary Search Algorithm

The recursive binary search algorithm works by dividing a randomly generated list of numbers between 0-100 into halves, checking if the user's number matches the middle element of each half, and eliminating halves where it does not match. This process recursively divides the remaining half lists in half until either the user's number is found or the sub list size reaches 0, indicating the number is not present. It uses a divide and conquer approach to search for the number recursively rather than iteratively.

Uploaded by

medha tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Binary Search Algorithm

The recursive binary search algorithm works by dividing a randomly generated list of numbers between 0-100 into halves, checking if the user's number matches the middle element of each half, and eliminating halves where it does not match. This process recursively divides the remaining half lists in half until either the user's number is found or the sub list size reaches 0, indicating the number is not present. It uses a divide and conquer approach to search for the number recursively rather than iteratively.

Uploaded by

medha tripathi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Recursive Binary search algorithm

Problem statement:
• Create a random list of numbers between 0 and 100 with a
difference of 2 between each number.
• Ask the user for a number between 0 and 100 to check whether
their number is in the list.
• The programmer should work like this. The program will half the
list of numbers and see whether the users number matches the
middle element in the list. If they do not match, the programmer
will check which half the number lies in, and eliminate the other
half. The search then continues on the remaining half, again
checking whether the middle element in that half is equal to the
user’s number. This process keeps on going until the programmer
finds the users number, or until the size of the sub array is 0,
which means the users number isn't in the list.
Recursive Binary search Algorithm:
• This search algorithm works on the principle of
"Divide and Conquer".
• Recursive algorithm, a function calls itself again
and again till the base condition(stopping
condition) is satisfied
• In the case of Iterative algorithms, a certain set
of statements are repeated a certain number of
times until it is done.
Outputs:

If number is present If number is not in list


Thank you

You might also like