for(j=0;j<n;j++)
{
if(a[j]==j)
return j;
else
continue ;
}
this shud also be correct right ??
On Mon, Aug 15, 2011 at 12:31 AM, Akash Mukherjee <[email protected]>wrote:
> just my 2 cents ---- in d binary search, replacing key with mid, ie
> if(a[mid] > mid)
> check lower half
> else upper half
>
> should work??
>
>
> On Mon, Aug 15, 2011 at 12:26 AM, aditi garg <[email protected]>wrote:
>
>> Given an ordered array A[1…n] with numbers in strictly increasing
>> order. Find a ‘j’ such that A [j]=j or -1 if no such number exist in
>> o (log n).
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.