ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write an algorithm which can find the largest number among
the given list using binary search ...............
this was asked in the interview
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview
Answer
# 1
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 ?    5 Yes 5 No
Vishnu948923
[No]
 
  Re: write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview
Answer
# 2
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 ?    5 Yes 3 No
Shruti
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
write a own function for strstr LG-Soft1
study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above Accenture13
how to make c program without a libary? e.g.#include<stdio.h> libary is not in c progaram.  1
How to avoid structure padding in C? Tech-Mahindra4
What is the real difference between arrays and pointers?  11
Sir i want e-notes of C languge of BAlaguruswami book i.e scanned or pdf file of balaguruswamy book on c language.PLEASE SEND ME on my mail id ajit_kolhe@rediff.com  4
f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=? Geometric-Software2
I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....  2
difference between my-strcpy and strcpy ? Geometric-Software3
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks Excel4
If we give two names then this displays the connection between the two people. It is nothing but flames game  1
Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.  2
2. What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value Accenture2
why division operator not work in case of float constant?  1
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?  2
What are the uses of pre-processor directives?  2
What is the Difference between Class and Struct? Motorola9
which of the function operator cannot be over loaded a) <= b)?: c)== d)* HCL7
How to add two numbers with using function?  3
who will call your main function in c under linux?  2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com