Frage im Vorstellungsgespräch bei Google

How to efficiently sort a pivoted array

Antworten zu Vorstellungsgespräch

Anonym

21. Okt. 2010

1. Find the pivot. 2. Reverse the left side until the pivot. 3. Reverse the right side after pivot. 4. Reverser the whole array. No need for extra storage and it's still O(n).

1

Anonym

25. Sept. 2010

Array is already sorted so 1) find the pivot point (use modified binary search) 2) since it is a array, block copy data using temporary buffer to reconstruct the sorted array