write an algorithm which can find the largest number among
the given list using binary search ...............
this was asked in the interview
Answers were Sorted based on User's Feedback
Answer / shruti
In binary search , we have sorted array.
Hence the last number in the array is the largest number
among the given list.. :-)
Ur interviewer has to be very intelligent.. :-)
Gud ques though..
| Is This Answer Correct ? | 18 Yes | 5 No |
Answer / vishnu948923
void main()
{
int a[10],i,flag,mid,low=0,high=9,num;
printf("enter how many elements");
scanf("%d",&num);
for(i=0;i<=9;i++)
scanf("%d",&a[i]);
for(mid=(low+high)/2; low<=high;mid=(low+high)/2)
{
if(a[mid]==num)
{
printf("Element position %d",mid);
flag=0;
break
}
if(a[mid]>num)
high=mid-1;
else
low=mid+1;
}
if(flag)
printf("element not present");
}
| Is This Answer Correct ? | 16 Yes | 14 No |
Write a C++ program to give the number of days in each month according to what the user entered. example: the user enters June the program must count number of days from January up to June
Why do some versions of toupper act strangely if given an upper-case letter?
multiple of 9 without useing +,* oprator
how can i include my own .h file EX:- alex.h like #include<alex.h>, rather than #include"alex.h"
What is c programming structure?
what different between c and c++
Why we not create function inside function.
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
main() { intj; while9j<=10) { printf("\n%d",j); j=j+1; } }
what are the uses of structure?
Develop a flow chart and write a c program to find the roots of a quadratic equation ax2+bx+c=0 using switch and break statement.
What is ambagious result in C? explain with an example.