You are on page 1of 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