Social Icons

banner image

TRAVERSING

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int lb, ub, item;
cin>>item;
lb=0
ub=n-1;
mid=(lb+ub)/2;
while((a[mid]!=item)&&(lb<=ub))
{
if(a[mid]<item)
{
lb=mid+1;
cout<<mid+1;
}
   else
   {
    ub=mid-1;
    mid=(lb+ub)/2;
    cout<<Not present;
}
}
getch();
}
TRAVERSING TRAVERSING Reviewed by Shobhit Goel on September 11, 2015 Rating: 5

No comments:

Airtel Hackaton 2017

Powered by Blogger.