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.
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.
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)
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?
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.
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.
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: ...]
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.
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.
[+] [-] glymor|16 years ago|reply
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
[+] [-] cschneid|16 years ago|reply
[+] [-] memoryfault|16 years ago|reply
[+] [-] snprbob86|16 years ago|reply
The bug is at the very bottom of the file.
[+] [-] dchs|16 years ago|reply
// Genereate random browser order
[+] [-] nomoresecrets|16 years ago|reply
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
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
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
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
[+] [-] unknown|16 years ago|reply
[deleted]
[+] [-] andrewcooke|16 years ago|reply
[+] [-] jasonlotito|16 years ago|reply
[+] [-] pohl|16 years ago|reply