Re:I cheated on my Microsoft interview (2019)
by buzzdenver on Sunday June 05, 2022 @10:53AM
(#31631493)
Stuff like whether the algorithm will always stop, or whether it runs O(N) vs O(N square). The main point to me was more to be able to have a conversation about the solution rather than it being absolutely right. I remember quite a few people using randomness, the most odd (and totally wrong) one using a random sort function over an array of (1..52).
[ Parent
| on HN ]
Why is the random sort wrong?
Re:I cheated on my Microsoft interview (2019)
by buzzdenver on Monday June 06, 2022 @07:33AM
(#31639169)
Random sort meaning that sometimes a>b, other times a<b for the same values. Whatever algorithm a language's built in sort implements probably assumes that comparisons are consistent. I remember checking a few versions of perl and some created a core dump iirc.
Ah okay. Thought you meant using something like shuffle in Ruby.
I do wonder what the result of doing a randomized sort like that would be. Probably not really random. Feel like numbers near the median would be overrepresented in the middle of the array.