This is an interview question.
In the first part I was asked for finding a minimum value in a sorted array that was rotated (for example, the sorted array [1,2,3,4] was rotated to [3,4,1,2] ).
The algorithm for doing it can be found here.
Then I was asked for improving the algorithm by using parallel computing. That was my suggestion:
- Assuming we can run
kthreads in parallel, divide the array intokequal size sub arrays (besides perhaps the last part). - Perform the algorithm above on each of the
ksub arrays. - Return the minimum value from the
kalgorithm runnings.
The interviewer said the algorithm run time isn’t good enough. Do you know a better solution?