it has some errors..lemme modify it On Sun, Sep 25, 2011 at 10:45 PM, Dheeraj Sharma < dheerajsharma1...@gmail.com> wrote:
> Q1 > int fun(int arr[],int left,int right,int num) > { > > int mid=(left+right)/2; > if(mid==0) > return 0; > if(mid==num-1) > return 1; > if( arr[mid]<arr[mid-1] && arr[mid]<=(arr[mid]+1)) > return (num-mid); > else if(arr[mid]>=arr[left]) > return fun(arr,mid+1,right,num); > else if(arr[mid]<=arr[left]) > return fun(arr,left,mid-1,num); > > } > > fun(arr,0,size-1,size) > > COrrect Me if am wrong.. > > > On Sun, Sep 25, 2011 at 9:39 PM, prasanth n <nprasnt...@gmail.com> wrote: > >> @ Decipher: >> Q1) find where the rotation begins and do binary search in the first half >> or the second half depending upon the search element >> >> >> On Sun, Sep 25, 2011 at 8:58 PM, Decipher <ankurseth...@gmail.com> wrote: >> >>> Q1) A sorted array is rotated unknown number of times , write an >>> algorithm to search an element in this rotated array in O(log n) . >>> Hint : Modify binary search >>> >>> Q2) Write an algorithm to traverse a rectangular matrix spirally. >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/algogeeks/-/0WBV1uzAe5AJ. >>> 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. >>> >> >> >> >> -- >> *prasanth* >> >> -- >> 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. >> > > > > -- > *Dheeraj Sharma* > Comp Engg. > NIT Kurukshetra > > > -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- 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.