in Programming in C
346 views
0 votes
0 votes

I have a doubt in it..In the question they already send the parameter a = 0 , b = (n-1) , int x --> the elements that have to be find

but if(a<b) // holds true so it return -1 right ???

 

in Programming in C
by
346 views

8 Comments

I'm sorry if I am missing something, but how will you compare it in the first place?

What's the value of n-1?  It is not initialised anywhere and thus should throw an error.
0
0
but if(a<b) // holds true so it return -1 right ???

I'm unable to get this part @magma
0
0

Hemanth_13

facing same problem but the answer given is B

but if in the condition if(a > b) // then I think ans B is correct  

0
0

what you think @Hemanth_13 ??

goxul  read the question again

0
0
I read the question. We are calling doSomething(arr, 0, n-1, x).  We do a similar when do a binary search too, but there, we define the value of n before passing it to the function. Here, we have passed an undefined value (n-1) to the function.  What value will the compiler interpret as for n-1? Unless there is an implicit assumption that the value of n has already been calculated and passed to the function with the compiler knowing.

Even then, it will always exit in the first step as 0 will be less than n-1 for any array having more than one element. If a > b was the condition, then the question makes sense and B should be the answer.
0
0
yeah correct  @goxul
0
0
Its a typo..B would be correct only when a>b.
0
0
yes, ACE test has many typos and that makes confusion :(
0
0

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
1 vote
1 vote
0 answers
2
Nils asked in Databases Nov 13, 2017
166 views
Nils asked in Databases Nov 13, 2017
by Nils
166 views