How Binary Search Makes Computers Much, Much Faster

Tom Scott

818 t. näkymät67

    Featuring binary versus linear search, and non-clustered indexes. Uh, indices. However you want to say it. • MORE BASICS:
    Written with Sean Elliott SeanMElliott/ • Camera by Tomek • Graphics by William Marler
    I'm at
    on Twitter at tomscott
    on Facebook at tomscott
    and on Instagram as tomscottgo

    Julkaistu 6 kuukautta sitten


    1. Tom Scott

      I am, as ever, extremely thankful for animator William Marler for handling all the graphics here!

      1. BrewDiePie

        Information. I.e books, are mostly changing with the 3-5year paradigm. So why not sort by release date?

      2. Maty Lojda

        Hmm video is uploaded a month ago, but Tom written this comment 3 months ago? Wierd

      3. Dennis Bautembach

        how can there be a 3-month old comment on a video uploaded 2 months ago?

      4. Joshua Murillo

        This video is great, as per usual, but it's particularly awesome that you added that bit about Dewey. This is what needs to happen, an extra 10s to give context, not much, but so worth the time. Thanks

      5. Dan Mahoney

        A113, eh?

    2. Alexander Kurt

      4:21 Don’t tell me that screen has T-Series on it

    3. bybeetho

      *Wow, Very good. ... Muito bom. ... Très bien. ... Beetho, da "Boomerang Flowers Band ®", de Belo Horizonte (MG), Brasil.*

    4. GH1618

      Now do one on the B-tree.

    5. Tryaz EVE

      I don't know why you felt that you had to denounce Dewey... weird

    6. nosuchthing8

      It's simple. Would you look for a phone number in a phone book starting at page one, and reading every single page until you find the name? No. You break the phone book in half, see which half the name is in then keep repeating.

    7. Matthew Poynter

      Real OGs get the curious George reference

    8. Fridays For Future

      On a smaller scale linear search is often faster because of cpu pipelines

    9. Mystical Apple

      0:19 The attention to detail here is incredible. Besides the obvious joke about Tom’s red shirts, John Scalzi is an actual author that wrote a book called _Redshirts_

    10. nonfictionalfictivename fictivname

      Binar search is used just for ordered list not unordered

    11. Roger Szmodis

      Pathetic human race. Arranging their knowledge by category just made it easier to absorb. Dewey, you fool! Your decimal system has played right into my hands!

    12. Steve A

      Brilliant !!!! 👍🏻👌🏻👍🏻👌🏻

    13. Christian Nicolaisen

      Doesn't databases typically use balanced trees, not binary ones? They are very much related, but balanced trees takes makes sure sorted input doesn't result in a lopsided tree. They also uses the fact that data is usually bunched together in storage medias.

    14. Perhaps

      Aside from the design of google's indexes, the reason that their searches are so fast is because they store 100% of their indexes in RAM -- and very fast RAM on very fast computers. They build their indexes off-line. Once built, they copy them to one of their RAM-based index servers. Once copied there, they then add that index server to their client pool. it is the computers in the client pool that we interact with when we make a search request (not directly, because we go through firewalls and load balancers -- but our search requests hit those RAM index servers). So people making search requests never see the work, and delays, behind the scenes, that go into creating the indexes. We are simply given access to those indexes, when someone at google adds a now-ready RAM index server to their pool of computers that process our requests.

    15. Riley Carpenter


    16. Google User

      Same as genders, if you treat it as binary, you can advance society much much faster

    17. MikeyMonkey

      Things I learned today: How binary searches work. Dewey was a terrible human being.

    18. Paul

      Don't recommend WhatsApp.

    19. Michael Roditis

      Laughing in hashmap

    20. Ryansleftboot

      Tom, I do not know how you find the time and effort to produce these videos but they are brilliant! Top one. Nice one. Get sorted.

    21. Joel Varghese

      Missive respect to google for optimizing the algorithm I wish it was open source.

    22. Winston Smith

      Girls eyes

    23. Robert Martin

      I don't disagree with any of Tom's criticisms of the man's moral failures, but hearing a guy like Tom complain about how evil a historical figure was makes me want to die a little bit.

    24. Weeping Angel

      All the schools and libraries I’ve been to still use dewey’s system for nonfiction

    25. Senthil Kumar Palanisamy

      Excellent explanation Tom, I never found one like this on binary search in youtube. Thanks for the content

    26. Zaid Lacksalastname

      smart guy from the past starter pack: Eugenics prof That's it

    27. Dar Brett

      Don't you hate it when you notice Tom Scott say you can't do something, and you say to yourself "Wrong! You can use multiple indices and there should be a tiny overlap, if any, to sort through after" and then Tom says "Unless you uses indexes" and it makes your entire train of thought redundant.

    28. Dan Duncker

      Still Google search isn't perfect

    29. KeyStroke

      What kind of computers are those next to you? They look just like the ones I used at the phone company from 1998-2002ish (when we finally got color monitors.)

    30. LANBros

      The tame robert epidemiologically rot because headlight hisologically untidy down a broad tights. utopian, encouraging sail

    31. Tano


    32. guywithknife

      “It doesn’t make much difference for eleven cards”, if anything it actually makes searching small datasets slower than linear search since linear search is cache and prefetch friendly while binary search is not. You need enough items in the dataset so that the search time is dominated by the items rather than cache thrashing.

    33. BrewDiePie

      Information. I.e books, are mostly changing with the 3-5year paradigm. So why not sort by release date?

    34. David Clift

      Well seven months later the search take longer but returns 100,000,000 more results!!

    35. KingPatrick 12

      God I'd love to talk with Tom.

    36. Pigman Rocker

      Sorting by colour is psychopathic and stupid. You cant change my mind. It doesnt make sense. Breaks as soon as a series has different colours.

    37. Michael Watts

      4:02 genuinely expecting Tom to say “a cluster ****” 😂

    38. Draqonboy

      Can we point out how great the "The Basics" sound is?

    39. Joseph Cohen

      Goes to show terrible people can still have good ideas

    40. Bruno Oliveira

      When I selected the video, I didn't know what was going to be about. And suddenly I remembered every time i had to access data from an SQL table. The term "did you put an index in that table" was say out loud every time a process was taking to long.

    41. Ana Ibrahim

      this is what we call it a video thanks so much for the efforts

    42. c182SkylaneRG

      Another thing to remember: make sure your computer isn't programmed to index the index. I was wondering why my index file was 263 GB on my 500 GB hard drive, and someone told me to make sure the index was excluded from itself. Whoops! :)

    43. Igor Patricio

      I like the way you explains me things like I was an 3 years old baby with defunctional brain, so I can understand everything

    44. Buba Vunga

      0:18 this looks like a book Tom would read


      Truely great information.

    46. Josef Thörn

      Dewey - The Andy Rubin of his time...

    47. Fat Fuck

      Dewey is a fantastic example of an uncomfortable truth. Sometimes terrible people can do great things.

    48. Sacha Scarabello

      mmmmMMMmM bogos binted

    49. lennyp18

      Nice tip of the hat using A113!

    50. urkerab

      It's quite simple: Database indexes contain the indices of the data, but in a different order, so you can quickly search the index to find the index of the original data you wanted.

    51. James TSY

      Chinese dictionaries also have indexing by radicals, on top of the stroke count and pages. Radicals are memorable visual components of many Chinese characters, and often carry a unified meaning to characters who share them, e.g. characters with 亻are usually human-related, or characters with 氵are usually water-related. Certainly has more meaning as an index than colour (to me), though ofc not all indexes need a deeper meaning anyway, as long as they get the job done....

    52. Joe dlvr

      Oh wow when i got taught about this in school i didnt think dewey was a sexpest

    53. CookingAndJava

      linear search is very often faster than binary search because of cache prefetching.

    54. Nora

      Oh, this video gave me a big wave of high school flashbacks. That sequence of cards really brings back memories, haha.

    55. Jounan

      Wow, Dewey seems like a cool gu-... oh god..

    56. ScorixEar

      *Indexes Indizes = multiple registers Indexes = multiple indexes in a database Tought by my university professor in Germany

    57. jon pazowski

      who says sexsism and rasism is bad, it can be an indication of wrong that is ignored by some like you apparenty

    58. Jonas Antonsson

      Well, you normally use a hash table for the primary key index, not rely on binary search for that. Binary search is common for other indexes though.

    59. sagacious03

      Neat video! Thanks for uploading!

    60. Styil

      >there are two ways a computer can search, linear or binary Laughs in hashmap

    61. Joel Murphy

      pedobyte (n.) the amount of data storage used by the average nonce.

    62. Blair the cat

      That’s some GREAT green screen

    63. Gaurav Kar

      If life is a Search for Meaning it better be Binary Search

    64. Jorge Martínez Blanco

      A113 easter egg on a Tom Scott Video? More likely than you think.

    65. YourBoiAbdo

      2:01 HP: 1000 T-SERIES anyone notice this? i thought it was just a mistake but nevermind.

    66. RussetPotatoe

      I always have to use linear search, it's because I'm non binary

    67. Zombie

      T-Series easter egg? 2:00

      1. Mr. Hat


    68. januzi2

      5:36 I'm using the triangle to describe the struggle between CPU, ram, and disk space. The size of the triangle is showing the size of the impact on the system that the program will have.

    69. AbyssOf _Saints

      But Wiggle Ferret

    70. Cactus

      Dewey based system lmao cry harder about it and NYW

    71. Gerwin Kiesinger

      life is about 3 things, getting bitches, getting money, and the dewey decimal system - Bo Burnham

    72. Weldeborn

      How can anyone dislike a video like this? Great work as always!

    73. Hjominbonrun

      nicely described.

    74. B Things

      *Indexing:* Do you want to be lazy now or in the future?

    75. Brian Kelly

      Can you use this on Microsoft folder sorting?

    76. Ariel Almeida


    77. Simon Humby

      Yet Windows takes forever to search my computer?

      1. Mystic-Malevolence

        Most likely windows explorer is set to search file contents as well--if you turn that off, it'll only search filenames, which is far quicker.

    78. ılılıᴘᴀʟᴇʙʟᴜᴇᴅᴏᴛɢᴜʏılılı

      Great to see matt parker in a tom scott video

    79. TheMightyKinkle

      I'm interested in Dewey's sexual deviences now

    80. Khunark

      long live racism! you will never silence the truth!

      1. Mr. Hat

        Great joke

    81. Michal Nemecek

      Thanks to Melvil Dewey we don't need to ask the librarian where a specific adult book is.

    82. Luke Gibson

      I don't know how they do it, but I've got a search program that requires no indexing and is able to return over 2 million results across 4.68TB of data, in 5.63 seconds. Ultra Search, it's free too.

    83. MidnightSt

      offtopic, but in my opinion: index, as the whole list - plural from that (many lists) is indexes. index, as a one number (id) - plural (many numbers where each serves as an id) indices.

    84. Umm Probably No one

      But google doesn't use the binary search ,does it ?

    85. Umm Probably No one

      Could you explain Page search next ?

    86. Edmund of the Angles

      When a corporate type like TS says someone was bad you know he's just covering himself

    87. Tony32

      Dewey would have become president today 🤣

    88. Mihoshika Furude

      .. What kind of idiot would go into a book store, and ask by color?

    89. Peter Tuijtjens

      The most amazing thing about binary search: If searching through x items takes (a maximum of) n comparisons, when you double the amount of items only takes n+1 comparisons. So with a 100.000 it's 16 times, 200.000 takes 17 tries.

    90. John Heilman

      There are many more strategies than just linear/binary to search a list. Easy Example: Probabilistic based upon guessing the distribution of the remaining items to be searched and where you should guess to maximize the speed at which you narrow the search space.

    91. fish say helo

      Please tom, 60 fps. My poor eyes

    92. grendelkeep

      I still remember the time when the transition happened from Yahoo or Altavista (or metacrawler or however that was called), yielding results in 2-3 seconds, to that new thing, Google, without anything on the landing page except that search bar - and giving the results in *fractions* of a second. And they were so much better, so much more accurate, they found so many more sites! It was mind-blowing.

    93. Chris

      For a minute I thought you were talking about John Dewey and I was so confused lmfao

    94. Dennis Bautembach

      except when it doesn't.. (cache, memory prefetch)

    95. Hellscream Games

      Good video.

    96. Naim From Earth

      So Melvis Dewey is the R. Kelly of librarians?

    97. Haverja Marosi

      1:40 as we will Michael Jacksons aswell. If you do something good, it stays good regardles of what bad you have done.

    98. John Mazur

      Hi Tom. having a pedantic moment. The computers speed does not change. What has been achieved is a faster algorithm that provides results quicker. The poor old computer is non the wiser, it still runs at its designed speed regardless of what is being executed.

    99. DAVE D

      thats were T O C comes in

    100. Dennis Premoli

      No scott, It's froo big to small.