Microsoft Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
Microsoft didn't ask you that. Stop trying to cheat on your randomized algorithms homework.
is that array s sorted of what kind of array it is? if it is a random array with repeated elements distributed randomly then i dont think there will be any algorithm to find the element rather than just traversing the array...
Correct me if am wrong! (c)
WTF, the guy told you, LAS VEGAS ALGORITHM. noone read the question?
If you do merge sort, then you can check if the pivot point is at n/2 in the entire array, if yes, then return. I should be careful about n (odd or even).
- Anonymous December 07, 2012Then use randomly merge sort, you should get O(log(n)) on average, however worst case is still O(n). You cannot do better.