#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();
}
#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
Reviewed by Shobhit Goel
on
September 11, 2015
Rating:
No comments:
Post a Comment