Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

write an algorithm which can find the largest number among the given list using binary search .......

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

write an algorithm which can find the largest number among the given list using binary search .......

void main()
{
int a,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

More C Interview Questions

What is action and transformation in spark?

What kind of structure is a house?

Write a C program in Fibonacci series.

What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?

In which mode we open the file for read,write and append also in c ? a)W b)w+ c)r+ d)a

The difference between printf and fprintf is ?

What is the scope of static variable in c?

main() { enum{red,green,blue=6,white}; pf("%d%d%d%d", red,green,blue,white); return 0; } a)0 1 6 2 b)0 1 6 7 c)Compilation error d)None of the above

Write a program to check whether a number is prime or not using c?

Between macros and functions,which is better to use and why?

int a=1,b=2,c=3; printf("%d,%d",a,b,c); What is the output?

How can I find out how much memory is available?

Categories
• C (4646)
• C++ (3462)
• VC++ (653)
• Delphi (566)
• Python Related (3238)
• PHP Related (7341)
• Scala (340)
• R Programming (396)
• Kotlin (184)
• Apache Groovy (39)
• Ruby (245)
• Go Programming Language (139)
• Objective-C (429)
• Programming Languages AllOther (736)