[algogeeks] Searching Problems !!

2011-09-25 Thread Decipher
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

Re: [algogeeks] Searching Problems !!

2011-09-25 Thread prasanth n
@ 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

Re: [algogeeks] Searching Problems !!

2011-09-25 Thread Dheeraj Sharma
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

Re: [algogeeks] Searching Problems !!

2011-09-25 Thread Dheeraj Sharma
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(

Re: [algogeeks] Searching Problems !!

2011-09-25 Thread veera reddy
Sol for Q1 http://www.geeksforgeeks.org/archives/1068 Sol for Q2 http://www.geeksforgeeks.org/archives/10768 On Sun, Sep 25, 2011 at 10:55 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: it has some errors..lemme modify it On Sun, Sep 25, 2011 at 10:45 PM, Dheeraj