top | item 1157168

Doing the Microsoft Shuffle: Algorithm Fail in Browser Ballot

59 points| Flemlord | 16 years ago |robweir.com | reply

25 comments

order
[+] glymor|16 years ago|reply
Turning compare into a coin flip is a fun way to illuminate the underlying algorithm.

IE is said to use a heap/tree related sort[1]. The first thing a heapsort does is swap the last entry with the the front (where the front may have been swapped in the heapify step[2]). Thereafter it leaves the last entry alone.

Since the first entry in the unshuffled array is "Internet Explorer" if it survives the initial comparison it will always occupy the last (5th) place.

The other algorithms don't have a case with only one compare which is why they have more complicated distributions.

[1] - http://www.smallapple.net/rnd/art/how_does_your_browser_sort...

[2] - http://en.wikipedia.org/wiki/Heapsort

[+] mseebach|16 years ago|reply
That is an incredibly long essay to describe a very simple problem. Don't randomize an array the way Microsoft does on browserchoice, because it's not random.
[+] cschneid|16 years ago|reply
More subtly, don't ignore preconditions of methods. The custom sort method needs to implement several invariants, which the Math.random() approach ignores. This confuses the hell out of the sort algorithm (in turn, leading to non-random order)
[+] memoryfault|16 years ago|reply
Is this even what is shipping with Win7 EU? I would assume that the real browser choice screen is not in a browser window, and that this website was created quickly just to give people an idea of what it might look like. Do we even know who actually wrote the code?
[+] nomoresecrets|16 years ago|reply
The worst part about the implementation is that the browser icons often appear unsorted initially, and then the sort kicks in 0-5 seconds later, and they all shuffle.

This has caught me out at least twice by clicking on a browser icon to choose it, then the order changes after I clicked and the wrong browser installer is launched.

[+] awa|16 years ago|reply
Its strange that MS got this wrong as the shuffling questions is quite common in the Microsoft interview (as in many other).

Though I do wonder if it makes any difference, may be they are taking this as an opportunity to do some research testing, my personal opinion would be that the browser in the middle position might have a slight upper hand than others.

[+] Fixnum|16 years ago|reply
Perhaps this is Microsoft, or someone who works there, thumbing their nose(s) at the EU - after all, what monopolistic corporation wouldn't be bitter at not having been able to buy out such an influential quasi-government organization [edit: and, worse, be forced to advertise on behalf of one's competitors]?

Don't get me wrong: I'm no fan of MS or IE. But I can see why they might deliberately fail to implement this correctly. [edit: ...]

[+] kevinh|16 years ago|reply
So in essence, Microsoft just handed this off to one of their junior programmers and he wasn't aware of how to do random correctly.

I don't see this being a result of Microsoft's malevolence, merely a programmer's ignorance. I doubt that Microsoft would do something that would be caught while fighting anti-trust charges.

[+] CoreDumpling|16 years ago|reply
It might be an "oops" from a single programmer, but I thought a high-profile site like this would at least go through some basic code review. The bug isn't that subtle, either.
[+] jasonlotito|16 years ago|reply
Considering IE mostly shows up in the 5th position according to this article, who cares? Does it really matter? Mountain out of a mole hill.
[+] pohl|16 years ago|reply
Doesn't that depend on which positions are likely to be chosen by people? On what basis should we assume the 5th position is not favored?