The Smartest Algorithm No One Uses

PurpleMind

PurpleMind

89,102 views

Go to https://ground.news/landingV8/purplem... for a better way to stay informed. Subscribe for 40% off unlimited access to world-wide coverage through my link.

The Median of Medians algorithm is one of my favorites of all time -- remember the mean, median and mode from math class? These three quantities have been etched into my brain since elementary school. But as a fourth grader, finding the median in particular always felt harder than finding the mean or the mode. For the mean and the mode, you just have to scan through the numbers once to get the answer. But the median is the “middle value” of the data, so it seems like the best method to find it is to simply sort all the numbers and then go to the middle of the sorted list. However there’s actually a way to find the median just as efficiently as finding the mean or the mode… or there are actually two ways that we explore in this video, with the second one especially being just utterly amazing. It involves taking the median of medians of certain values, and it works out to be efficient because of a certain “magic number!”

Support me on Patreon! Patreon: PurpleMindCreations
If you'd like to aid the success of this channel, this is the best way to do it! Every contribution is sincerely, greatly, appreciated.

If you or your institution is interested in sponsoring the topic of a future PurpleMind video, please contact me via purplemindcs@gmail.com!

References:
This video was heavily inspired by the following lecture: https://www.cs.cmu.edu/~15451-f23/lec...
Inspiration for the experiments from the end of the video comes largely from this really nice blog post by Russell Cohen: https://rcoh.me/posts/linear-time-med...
Quicksort: https://en.wikipedia.org/wiki/Quicksort
Quickselect: https://en.wikipedia.org/wiki/Quickse...
Median of Medians: https://en.wikipedia.org/wiki/Median_...


Brittle Rille - Reunited by Kevin MacLeod is licensed under a Creative Commons Attribution 4.0 license. https://creativecommons.org/licenses/...

This video was made using Manim, by 3Blue1Brown.

Discord Server: Discord: discord. Feel free to join!
Business Inquiries: purplemindcs@gmail.com