|
|
|
Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time. Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?
--------------------------------------------------------------------------------
Implement the following function, FindSortedArrayRotation, which takes as its input an array of unique integers that has been sorted in ascending order, then rotated by an unknown amount X where 0 <= X <= (arrayLength - 1). An array rotation by amount X moves every element array[i] to array[(i + X) % arrayLength]. FindSortedArrayRotation discovers and returns X by examining the array. Consider performance, memory utilization and code clarity and elegance of the solution when implementing the function.
C++ Prototype
int FindSortedArrayRotation( int array[], unsigned length )
{
}
C# Prototype
static int FindSortedArrayRotation( int[] array )
{
}
--------------------------------------------------------------------------------
|
| Author: Vidya 23 May 2008 | Member Level: Diamond Points : 2 |
Useful information
|