{"id":339,"date":"2008-04-21T22:03:37","date_gmt":"2008-04-22T02:03:37","guid":{"rendered":"http:\/\/www.rakkar.org\/blog\/?p=339"},"modified":"2008-04-21T22:03:37","modified_gmt":"2008-04-22T02:03:37","slug":"how-to-pick-the-median-of-a-large-list","status":"publish","type":"post","link":"https:\/\/rakkar.org\/blog\/index.php\/2008\/04\/21\/how-to-pick-the-median-of-a-large-list\/","title":{"rendered":"How to pick the median of a large list"},"content":{"rendered":"<p>\t\t\t\tI keep reading about how Google always asks the interview question on how to pick the median of a large list in a distributed network. Here&#8217;s my answer, which I think is pretty optimal:<\/p>\n<p>1. Randomly divide the list equally among all computers.<br \/>\n2. Pick one element (the key) of the list at random.<br \/>\n3. For each computer, for each element in that computer&#8217;s sublist, compare that element against the key. If it is less, move the element to the lesser list. If it is more, move it to the greater list.<br \/>\n4. Add up the sizes of the greater and less than lists among all computers.<br \/>\n5. If the sizes are equal, the key is the median. Done.<br \/>\n6. Else set the list to the greater than list. Go to 2\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I keep reading about how Google always asks the interview question on how to pick the median of a large list in a distributed network. Here&#8217;s my answer, which I think is pretty optimal: 1. Randomly divide the list equally among all computers. 2. Pick one element (the key) of the list at random. 3. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/339"}],"collection":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":0,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"wp:attachment":[{"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rakkar.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}