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 <saurab...@gmail.com> 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 <techrascal...@gmail.com>wrote: > >> how to find distortion using binary search?? >> >> >> On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel >> <mohitgoel291...@gmail.com>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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.