Programming Examples

Algorithm for Binary Search


1.  Accept the element to be searched.

2.  Set lowerbound = 0.

3.  Set upperbound = n – 1.

4.  Set mid = (lowerbound + upperbound)/2.

5.  If arr[mid] = desired element:

a. Display "Found".

b. Go to step 10.

6.  If desired element < arr[mid]:

Set upperbound = mid – 1.

7.  If desired element > arr[mid]:

Set lowerbound = mid + 1.

8.  If lowerbound <= upperbound:

Go to step 4.

9.  Display "Not Found".

10. Exit.

Output

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad