"Coding is just like talking to a unknown girl. Once you talked to her with guts, the next time you'll never afraid",Really? Yes , try it Now !!!
Everything here is for education and learning purpose only , individual holds rights on outer posts/links etc.
Team Cracking The Code
About Me
▼
Sunday, December 11, 2011
Given an array of unsigned integers which is initially increasing (value of integers)and then decreasing find the maximum value in the array
Use Binary Search. Find the mid element. if(Arr[mid] > Arr[Mid-1] && Arr[mid]>Arr[mid+1]) return mid. else if (Arr[mid] > Arr[mid-1] && Arr[mid]< Arr[mid+1]) low = mid+1
ReplyDeleteelse high = mid-1.revise the search.