above is when the sorted array is in increasing order.
On Sat, Jul 30, 2011 at 11:56 AM, Ankur Khurana <[email protected]>wrote:
> low =lower_bound , high=upper_bound;
> int a=arr[low];
> while(low<high)
> {
> mid=(low+high)/2;
> if( arr[mid]>a && mid<upper_bound && arr[mid+1] <a)
> break; //you found the index of distortion
>
> if(arr[mid]>a)
> low=mid+1;
> else high=mid-1;
>
> }
>
> On Sat, Jul 30, 2011 at 11:46 AM, saurabh singh <[email protected]>wrote:
>
>> Look for the spike...that is the index where the sorted property is
>> disturbed.
>>
>>
>> On Sat, Jul 30, 2011 at 11:44 AM, tech rascal <[email protected]>wrote:
>>
>>> how to find distortion using binary search??
>>>
>>>
>>> On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel
>>> <[email protected]>wrote:
>>>
>>>> yes ..u r right ...thnks...
>>>>
>>>> --
>>>> 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.
>>>
>>
>>
>>
>> --
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT ALLAHABAD
>>
>>
>>
>> --
>> 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.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>
--
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.
--
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.