0% found this document useful (0 votes)
5 views1 page

Binary Search Algorithm in C++

The document provides steps to write a program that accepts elements into an array using binary search to find a number: 1) Start the program and declare classes/members; 2) Create an object to call functions; 3) Define functions to accept array elements and search using a loop that updates min/max indexes until the item is found and its position printed or not found is reported.

Uploaded by

Deep Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Binary Search Algorithm in C++

The document provides steps to write a program that accepts elements into an array using binary search to find a number: 1) Start the program and declare classes/members; 2) Create an object to call functions; 3) Define functions to accept array elements and search using a loop that updates min/max indexes until the item is found and its position printed or not found is reported.

Uploaded by

Deep Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Write a program to accept a elements into an array and search for a number using binary search technique.

Algorithm
Step Step Step Step 1-Start 2-declaring class chars and data members 3-Creating object of the class chars to call the function 4-Calling the function void accept() definition of void accept() accepting the string End function Step 5-Calling the function void search() Definition of void search while(max>=min) mid (max+min)/2 if(a[mid]<item) min mid+1 else if(a[mid>item) max mid-1 else if(a[mid]==item) print-item is present at+(mid+1)+position if(f==0) print-item+is not present End fucntion Step 6-End

You might also like