How Computers Compress Text: Huffman Coding and Huffman Trees

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024

Комментарии • 1,3 тыс.

  • @TomScottGo
    @TomScottGo  7 лет назад +3842

    This is the last of the three trial Basics videos! This pushed my quick-explanation skills to the limit, but I figure that "slow down the video and replay if necessary" is better than "let people get bored"...

    • @superhands290
      @superhands290 7 лет назад +15

      Are you bored of this realm?

    • @SiddheshNan
      @SiddheshNan 7 лет назад +15

      Tom Scott 2 days ago??

    • @timtjtim
      @timtjtim 7 лет назад +14

      These are really great - this one taught me something new, and I really do feel like I understand it now! If you do this again, and you go to the Computing Museum, will you let people know, or will it be a surprise? :)

    • @JohnR31415
      @JohnR31415 7 лет назад +6

      I know some people can't cope with the high speed delivery, and thus just stop watching - if YT had an easy 'slow this video down' button....

    • @terimarymags
      @terimarymags 7 лет назад +14

      We need more like this.

  • @xisumavoid
    @xisumavoid 7 лет назад +3751

    Would love to learn more about compression! This was fascinating :-)

    • @bonzaipineapple3143
      @bonzaipineapple3143 5 лет назад +296

      xisumavoid 😱 I love when someone I admire on yt also admires someone else I admire, I wish you both the best.

    • @zaimwaqar2788
      @zaimwaqar2788 5 лет назад +199

      Did not expect a Minecraft youtuber here!

    • @macaroon_nuggets8008
      @macaroon_nuggets8008 4 года назад +37

      Second comment I have seen from you on this channel!

    • @onionbot2
      @onionbot2 4 года назад +10

      wow uh hi

    • @TheScramblerTV
      @TheScramblerTV 4 года назад +17

      ecks eye zooma void

  • @WAYAWAYWithAsh
    @WAYAWAYWithAsh 7 лет назад +4233

    Dang, that last line got me. I want a series on more than just the basics now!

    • @miles4711
      @miles4711 7 лет назад +75

      WΔY ΔWΔY The channel Computerphile (where Tom also featured a few times) has something on Huffman coding. And a lot more interesting stuff.

    • @WAYAWAYWithAsh
      @WAYAWAYWithAsh 7 лет назад +70

      +miles4711 I also watch there. But Tom's approach here was well done in a way I hadn't quite seen before. That said, I'll look up those specific videos you mentioned. Thanks

    • @roderik1990
      @roderik1990 7 лет назад +16

      So basically, this method is the best given the frequency distribution of those single characters. But... if you have more information on how your data is distributed/patterned, you can get further compression by using those patterns.

    • @DeanyKong
      @DeanyKong 7 лет назад +27

      Right? I've got total blue brains now.

    • @Nadia1989
      @Nadia1989 7 лет назад +4

      Then I suggest you check out Crash Course Computer Science. It's a bit more than just the basics.

  • @TUTAMKHAMON
    @TUTAMKHAMON 7 лет назад +590

    It's amazing how every video that Tom puts out always has an incredible amount of attention to detail. Take for instance the increase in video compression when he talks about it (0:43), him saying "worms" instead of "words" when talking about (0:52) lossy text compression, and the fact that at (4:40) he does his gestures mirrored so it is our left and right and not his left and right. On top of that he does it all in one take. I'm always amazed when a new episode comes out.

    • @fredoverflow
      @fredoverflow 7 лет назад +29

      Speaking of one take, have you seen the ending to "Will RUclips Ever Run Out Of Video IDs?"? :)

    • @theodorlager4024
      @theodorlager4024 Год назад

      frletmiflm with their old kit

  • @SuperManitu1
    @SuperManitu1 7 лет назад +199

    3:00 God how I love the square sneaking of the screen

  • @grassyclimer6853
    @grassyclimer6853 7 лет назад +2040

    Tom if you keep this up people will realize its not magic. If I have to stop wearing my wizards hat to work Ill spell you so hard.

    • @traewatkins931
      @traewatkins931 5 лет назад +44

      Naa we just have to make doing the same thing more esoteric therefore appearing as advanced wizardry... just like we have for the last 20 years.

    • @thegamingsidedk9699
      @thegamingsidedk9699 5 лет назад +5

      Ömåå
      Å

    • @unlockwithjsr
      @unlockwithjsr 4 года назад +14

      Few people even watch RUclips videos like Tom Scott's and other educational stuff. Don't worry, most people are on music and entertainment.

    • @WillKemp
      @WillKemp 3 года назад +12

      @@traewatkins931 40 years. I started working as a programmer in 1979 😱, and that's how it was then 😂

    • @SerialElfYT
      @SerialElfYT 3 года назад +11

      @@unlockwithjsr for some of us this is entertainment

  • @hayleyxyz
    @hayleyxyz 3 года назад +84

    I've worked with various compression algorithms derived from Huffman and this is the best description of it I've seen.

  • @MasterJoJYTP
    @MasterJoJYTP 6 лет назад +13

    I've been binge watching your videos for the last few days procrastinating on my homework. Now my CS class has a question on a Huffman tree, and I end right back up here. Thank you, Tom. You made it super easy.

  • @steatopigeon
    @steatopigeon 7 лет назад +918

    Everyone's talking about Tom sending the wrong worms, but there's precious little talk about the video quality going drastically downwards as he talked about video/images being lossy compression right before that.

    • @krashd
      @krashd 7 лет назад +103

      Thus proving his point that some things like images or audio can be compressed using a lossy technique without losing any of the actual meaning (we could still see and understand a lower quality video.) you only loss detailing.

    • @NoriMori1992
      @NoriMori1992 7 лет назад +138

      I think that's because everybody noticed that and it was a pretty obvious and predictable joke, whereas "sending the wrong worms" makes people do a double take.

    • @willmcconnellsimpson1411
      @willmcconnellsimpson1411 5 лет назад +16

      I don’t think it was obvious, I thought it was inspired.

    • @artysanmobile
      @artysanmobile 5 лет назад +6

      Smittens Yes, I noticed that and wondered at the coincidence.

  • @HarryNewbury
    @HarryNewbury 7 лет назад +5188

    "... or you'll send the wrong worms" damn Matt, that joke was awful!

    • @DogsRNice
      @DogsRNice 7 лет назад +268

      I live how many of the comments are pointing that out and also changing one word in the comment as well

    • @Culmaerija
      @Culmaerija 7 лет назад +143

      at which point translators just gave up subbing the video ಠ_ಠ

    • @mckseal
      @mckseal 7 лет назад +231

      "Send Words" changing one letter becomes "Send Worms", becomes "Sand Worms", becomes THE SPICE MUST FLOW

    • @yyny0
      @yyny0 7 лет назад +49

      'Matt'

    • @JimPlaysGames
      @JimPlaysGames 7 лет назад +100

      Are you kidding? That was grape!

  • @lawrencecalablaster568
    @lawrencecalablaster568 7 лет назад +166

    I never thought that Wild Wild West would ever be used to such a profound effect. Well done, Tom.

    • @pepper669
      @pepper669 7 лет назад +2

      To me, "Wild Wild West" is the least memorable movie in the history of cinema. OK, maybe except maybe for "Ishtar".

    • @frickyou1045
      @frickyou1045 7 лет назад +19

      You have obviously never heard the masterpiece Wow Wow by the legend Neil Cicierega

    • @pepper669
      @pepper669 7 лет назад

      Thanks for the tip! Maybe I'll even watch it (or try to do so :) ).

    • @uninstallyourheart
      @uninstallyourheart 7 лет назад +1

      Walter Lowe I KN E W I WASNT THE ONLY ONE WHO CAUGHT THE REFERENCE

    • @cirlu_bd
      @cirlu_bd 4 года назад

      try Wow Wow by Neil Cicierega, I can assure you Wild Wild West (and All Star if you fall into the rabbithole that is Neil) will have a brand new type of impact on you !

  • @Mikomen97
    @Mikomen97 7 лет назад +910

    During my encoding class I had to write a program that compresses files with huffman coding. As I was turning back my program the professor asked me:
    -Where is the source code?
    -Oh here, you just have to decompress it with my program.

    • @rmsgrey
      @rmsgrey 7 лет назад +28

      How many quines did you submit?

    • @Mikomen97
      @Mikomen97 7 лет назад +20

      I'm not sure if it counts as a quine as it takes an external file

    • @iabervon
      @iabervon 7 лет назад +144

      "You know how I was supposed to be picking a version control system? Well, I decided I didn't like any of them, so I wrote my own and checked it into itself. I put the repository on my web site..."

    • @Mikomen97
      @Mikomen97 7 лет назад +131

      Yeah once I was like "Wait does git has it's own repo where it keeps track of itself? (check) oh actually it does". Another thing is that gcc is written in c, so it can compile itself.... moreover it can compile a newer version of itself

    • @AndersJackson
      @AndersJackson 7 лет назад +64

      There are many program languages that are programmed in themself, and are compiled by itself. Nothing strange there. Look up Bootstraping.

  • @ceruchi2084
    @ceruchi2084 5 лет назад +60

    Yo, the YT algorithm is giving me a Tom Scott renaissance right now and it's all so good. Love this guy!

  • @connorbunch3577
    @connorbunch3577 3 года назад +10

    Wow! I can't believe you just explained something that you would learn at a university lecture, but in a way that was so thoroughly entertaining!

  • @ImSquiggs
    @ImSquiggs 7 лет назад +15

    THANK YOU TOM SCOTT!! I have wondered how compression like this worked for the better part of a decade, and I've even put a decent amount of time into researching it, but it never clicked until this video. You have the best content on this entire platform, both in subject matter and quality.

  • @christopherharrington9033
    @christopherharrington9033 7 лет назад +19

    Basics videos are great. You're a good communicator, and it's fantastic for children doing computer science at GCSE.

  • @Dandaman955
    @Dandaman955 7 лет назад +13

    Always needed a clear and concise way of explaining Huffman Coding. Thank you!

  • @MickeyD2012
    @MickeyD2012 7 лет назад +1

    Tom Scott, you, sir, are a genius. Nobody has ever been able to explain something like this to me in such a simple fashion, I actually understand this now, and I could decode a file by hand with a Huffman tree now just from what I learned in your video.

  • @darkbyte2005
    @darkbyte2005 7 лет назад +3

    Wow, everyday I see that Huffman reference in my daily job and I use it to pack files, and I never new it was a masterpiece of software engineering. thanks for explaining it so well

  • @xdxnisx
    @xdxnisx 3 месяца назад

    Studying for a computer science exam about datastuctures and I am very glad that I can watch a Tom Scott video in my study session

  • @NALGames
    @NALGames 7 лет назад +7

    Would love to see more of these. Even when I already know about what you're explaining, your videos are so superbly made that they're still fascinating to watch.

  • @pedromusic7986
    @pedromusic7986 Год назад +1

    This guy really seems like he LOVES to teach what he knows and is passionate about! I'm really enjoying the enthusiasm as well as the knowledge being shared. This is so good❤

  • @dewj8323
    @dewj8323 7 лет назад +27

    This is an absolutely amazing series. I hope there will be more in the future!

  • @ChaseCarlson
    @ChaseCarlson 18 дней назад

    literally better than my entire CS class in 6 mins 30 secs. thanks Tom!

  • @arbitrario3845
    @arbitrario3845 3 года назад +3

    3:02 I love how the pointer gets so angry it just leaves

  • @kn0bhe4d
    @kn0bhe4d 7 лет назад

    I'm always amazed at how many clever people are in the world, with solutions to problems that I know I could never have come up with.

  • @goku_dunker_420
    @goku_dunker_420 7 лет назад +6

    "The wrong worms" Godlike writing, nice job tom

  • @aryaveer7500
    @aryaveer7500 Год назад

    6 minutes of proper clear information. my professor took a lecture of 30 minutes and still could not explain it half as good as you

  • @izzyhope58
    @izzyhope58 2 года назад +29

    This is really cool. Honestly really curious as to how the tree itself is stored. That would be really cool. Tbh I want Tom to teach a whole computer science basics class.

    • @blomblegle
      @blomblegle 2 года назад +2

      What I did was to store in the header of the compressed file the preorder traversal of the tree and then an array with information about which nodes are leaf nodes. You could also store combination of 2 different traversals, but "my" solution would only take up to [number of nodes] + ceil([number of nodes] / 8) bytes - not that significant difference, but still a difference :P

    • @rigveddesai5843
      @rigveddesai5843 Год назад

      idt the tree itself is stored it is just used to create the translation list which is used to compress the data, then you can send the list and the compressed data

  • @graf
    @graf 7 лет назад

    I've got an exam tomorrow, and one of the topics happens to be Huffman code. Thanks Tom!

  • @jalcome4201
    @jalcome4201 7 лет назад +31

    When he talked about images and the screen went low q I thought it was my connection! Well played!

  • @learningCodingWithMe
    @learningCodingWithMe 6 месяцев назад

    This is amazing. I am a CS student, and needed to implement a huffman algorithm as an assignment. There's an explanation in the assignment about the huffman algorithm, but it's really poor.
    Having watched this video before, I came back to see if it could explain the algorithm, and Tom nails it. The algorithm is explained well in a way that both the layman and the experienced can understand. Tom is an excellent communicator!

  • @Bildungsromancuddy
    @Bildungsromancuddy 7 лет назад +266

    "But text has to be losslessly compressed: you can't just lose a bit of detail, otherwise you end up sending the wrong worms." 🤣 Nice play there Tom!

    • @KaosFireMaker
      @KaosFireMaker 7 лет назад +18

      Along with the fact that video compression artifacts were added just before that

    • @zebronki
      @zebronki 4 года назад +1

      @@KaosFireMaker such a nice little touch!

    • @Christian-mn8dh
      @Christian-mn8dh 2 года назад

      i dont get it

  • @bytenik
    @bytenik 7 лет назад

    I teach Huffman Coding to my intro to programming students at Stevens Institute of Technology, an engineering university in Hoboken, NJ. Starting this semester, I will absolutely be showing them this video prior to them working with Huffman Coding!

  • @bossgaming4469
    @bossgaming4469 3 года назад +4

    Thank you very much Tom. I’ve had a hard time understanding Huffman trees in school so that really helps me!

  • @spamfiltration5086
    @spamfiltration5086 4 года назад +2

    ayo you better give your editor a raise; this video is bang on

  • @ivanavalos3911
    @ivanavalos3911 7 лет назад +9

    This is magic. I've just finished my text compression algorithm in C++ the day before yesterday, and this video was uploaded. I feel I'm being observed.

  • @cinergiflims
    @cinergiflims 7 лет назад

    love that your getting back to the educational stuff. Breaking down complicated topics in computing or explaining how a hack was done was always a fave.

  • @brayzbeats
    @brayzbeats 7 лет назад +448

    I love your videos. You make complicated things look so easy (altough I don't understand the technique and logic behind it anyway :D)

    • @kalebbruwer
      @kalebbruwer 7 лет назад +7

      brayzbeats. Doing this means the most commonly used characters end up at the top with the shortest binary codes.

    • @Ins4n1ty_
      @Ins4n1ty_ 7 лет назад +39

      It's pretty simple really. Huffman Trees are very straightforward.
      Think about a short tree, like this one:
      o
      / \
      o B
      / A
      o
      C D
      This means our alphabet has 4 letters. A, B, C and D. Now I want to compress a short text using this tree. The text is "DAB" (sorry, only thing I could think with these letters)
      So, we'll start by converting D into binary.
      To get to D, we gotta go to the left twice then to the right once, so here it goes: "Left Side: 0, Left Side: 0, Right Side: 1". So a D corresponds to 001 in binary.
      Now to get to A, it's 1 left and 1 right, so 01.
      Now to B, all I need is 1 right. so 1.
      This turns DAB into 001011. 6 bits of information.
      When you read this file, you'll convert 001011 back into DAB by doing the opposite process.
      You'll read bit by bit:
      0 -> go to the left once. It's not a letter yet so read next bit.
      0 -> Go to the left again, it's still not a letter so read next bit.
      1 -> Go to the right. Oh it's a letter, letter D. OK so writing it down on the output: D. Now reset to the tree root and read next bit.
      0 -> Left. Not a letter. Next Bit.
      1 -> Right. It's the letter A! Write it down to the output. DA. Reset to root and next bit!
      1 -> Right. It's the letter B! OK! Write it down to the output. DAB. There are no more bits to read so it's done! Your text is DAB!

    • @yesto9676
      @yesto9676 7 лет назад +7

      brayzbeats. I do understand these well, but math and engineering videos go past vocabulary and I have to watch them twice to understand sometimes.

    • @brayzbeats
      @brayzbeats 7 лет назад

      That's it.

    • @caramonfire
      @caramonfire 7 лет назад +3

      That helped a lot, thank you!

  • @seabiscuits
    @seabiscuits 7 лет назад

    A basics video with two machines who you programmed in 'basic'. Brilliant.

  • @SpartanMJO12
    @SpartanMJO12 7 лет назад +1448

    "You end up sending the wrong worms"
    Wow, that jake was funking awful

    • @pacha1500
      @pacha1500 7 лет назад +8

      im dying now

    • @flashylite
      @flashylite 7 лет назад +14

      It reminded me of this! ruclips.net/video/aJ0nFQgRApY/видео.html

    • @JohnyComeLately
      @JohnyComeLately 7 лет назад +4

      Hierophant yarn response was as goo as the original jack?

    • @seanthebluesheep
      @seanthebluesheep 7 лет назад +24

      Taikamuna It took me a couple of minutes, but I got it in the end. The wrong worms is "the wrong words" but worms is the wrong word.

    • @Draugo
      @Draugo 7 лет назад +2

      Before opening I assumed you would link this ruclips.net/video/pImWVCMgEYQ/видео.html

  • @izzyhopeunlisted
    @izzyhopeunlisted 4 года назад

    now I want a video how how the tree is actualy stored, how compresion for big chunks like words or phrases works and more. This is awesome

  • @ScarceAnari
    @ScarceAnari 7 лет назад +421

    Toms red T-Shirt probably has it's own insurance.

    • @ScarceAnari
      @ScarceAnari 7 лет назад +4

      Im proud

    • @DerekHartley
      @DerekHartley 7 лет назад +43

      Which one of the hundreds?

    • @oliilo1
      @oliilo1 7 лет назад +22

      And he's not even the guy known as "red shirt guy".
      Though I bet Tom use a green or blue shirt in public to avoid people recognizing him.

    • @williambrennan104
      @williambrennan104 7 лет назад +4

      *its

    • @ancbi
      @ancbi 7 лет назад +5

      He implements "redundant red shirt error correction scheme" explained in one of his other video.

  • @marcfuchs6938
    @marcfuchs6938 3 года назад +1

    Video 4 years old at this point, but relevant and awesome as ever. I am a big fan of compression, because I hate wasting anything in life. Hate wasting food, wasting water, wasting gas, wasting time......... And wasting space, physically and digitally! I like to experiment, what kinds of files can be further compressed through means like Winrar. Videos and images (like JPEG and PNG) usually can't be compressed any further, but I found out at some point, that for example Photoshop files (.psd) can often be heavily compressed. Depending on their content, really. But I have had compression rates of up to 93% on particular files. What a load of wasted space.

  • @thekarategirl5787
    @thekarategirl5787 7 лет назад +540

    Can you do a video on zip files?

    • @GoldenSun3DS
      @GoldenSun3DS 7 лет назад +11

      Do one on 7Zip and RAR, too.

    • @qwertyTRiG
      @qwertyTRiG 7 лет назад +8

      Karate Girl91 There are a lot of sophisticated compression algorithms. Zip, 7z, rar, gzip, deflate, bz2, botli, etc. Some of these are stream algorithms, and tend to work in a concert with tar to compress folders.

    • @samdouglas32
      @samdouglas32 7 лет назад +28

      It's not Tom, but Prof. Brailsford did a video explaining LZ77, which is still a very popular compression algorithm, variants are used in in ZIP, Gzip, RAR etc. It's easy to understand and a good place to get started if you want to learn more:
      ruclips.net/video/goOa3DGezUA/видео.html

    • @sophieloren9454
      @sophieloren9454 6 лет назад +2

      Ethan Pender has

  • @suesienchee23
    @suesienchee23 6 лет назад

    Bless you, Tom Scott! You managed to make me understand in 6 and a half minutes what my teacher couldn't in an hour.

  • @cube2fox
    @cube2fox 5 лет назад +67

    Surprised we didn't learn about Huffman coding in university. Could have been mentioned right after the sorting algorithms...

    • @wappa6914
      @wappa6914 4 года назад +6

      Trurl In my school we did it

    • @davictor24
      @davictor24 4 года назад +1

      @@wappa6914 my school too. Did an Information Theory course in my final year.

  • @chrisjlocke
    @chrisjlocke 7 лет назад +1

    I've been in IT about 26 years and learnt something from this video. Never knew how compression worked. Explained very clearly. Or vry clrly. Or 10010011000110001.

  • @CraftEngineer
    @CraftEngineer 7 лет назад +89

    Awesome presentation....inspired by you...I am an IT engineer...:wanna start my tech channel too after viewing your video and fan base....wish me good luck ☺️☺️☺️

    • @Phil8sheo
      @Phil8sheo 4 года назад +13

      Amazing to find this comment from you at the beginning of your channel! Now you have nearly 200,000 subscribers and that is simply amazing. Congrats!

    • @Martin__
      @Martin__ 4 года назад +7

      @@Phil8sheo Was thinking the same. Amazing!

    • @jimhalpert9803
      @jimhalpert9803 3 года назад +7

      This comment is amazing. Wow.

  • @discy12345
    @discy12345 7 лет назад

    I like it when you talk about something that combines computing science with mathemetics. you seem so passionate!

  • @InvisibleTower
    @InvisibleTower 7 лет назад +3

    This one of only two things I remember from my programming module - the other is a habit of typing both the open and close brackets at the same time.

  • @-TheBugLord
    @-TheBugLord 3 года назад

    Working on a paper about Huffman Encoding. Without any prior knowledge, this helped a ton.

  • @rrni2343
    @rrni2343 7 лет назад +30

    I love how you just seamlessly blend in jokes to your script.

  • @william_mazza
    @william_mazza 5 лет назад

    So... In about 6 minutes I have understood Huffman compression algorithm... WOW Tom you are a wizard

  • @am-bushgaming4811
    @am-bushgaming4811 3 года назад +74

    I like the dry humor, "Otherwise you say the wrong worms" is just objectively funny

  • @nqinadlamini
    @nqinadlamini 7 лет назад

    Thats where Limpel-Ziv strolled in and started using blocks.
    Thank for this, it is the best (that I've seen) explanation of Huffman.

  • @angadtendulkar292
    @angadtendulkar292 3 года назад +14

    0:46 I actually thought my wifi was acting up again

  • @alberteinsteinthejew
    @alberteinsteinthejew 4 года назад +2

    This channel taught me more than what I’ve learned in my 4-year computer science degree

  • @noaag
    @noaag 3 года назад +3

    This video was SUPER helpful! Thank you Tom!! I can't go to IRL classes right now - pandemic and all that - and this introductory video is the next best thing. And dare I say, my teachers are not as skilled at succinct explanations. Thanks!!

  • @MustafaOzanAlpay
    @MustafaOzanAlpay 4 года назад +1

    Well, I have my algorithms final tomorrow and I wanted to have a quick recap, Tom Scott nailing it, again. Thanks!

  • @meatdress8111
    @meatdress8111 7 лет назад +18

    0:50 Hilarious, reminded me of SCP-586 (Anything talking apple it has one typo.)

  • @charliespinoza1966
    @charliespinoza1966 7 лет назад +1

    Your presenting skills get smoother and smoother. Pretty soon you'll be doing ten minute, one-take videos (without blinking), on how to film one-take videos!

  • @yasminh
    @yasminh 2 года назад +3

    0:49 this was funny on so many levels, hope no one sends me any worms, my computer's laggy enough as it is

  • @retiredtom1654
    @retiredtom1654 7 лет назад

    I was able to understand more in your short video than any other attempts I have made in the past. Thanks!

  • @bradirv
    @bradirv 7 лет назад +7

    3:05 someone give the animator a raise 😂

  • @MrDaviddavo
    @MrDaviddavo 7 лет назад +5

    "... or you'll send the wrong worms" *5 seconds later* Nose Exaling

  • @HackThePlanetNow
    @HackThePlanetNow 7 лет назад

    The lossy compression bit was brilliant. Making it look compressed at the right time.

  • @ColtenPilgreen
    @ColtenPilgreen 7 лет назад +494

    "... or you'll send the wrong worms"

    • @uncreativename9833
      @uncreativename9833 7 лет назад +13

      Colten Pilgreen 😂 0:50

    • @SloeJuice
      @SloeJuice 5 лет назад +1

      Exposed! You need to make sure your computer virus is compressed properly? :D

    • @dkaloger5720
      @dkaloger5720 4 года назад

      Wong

    • @futrey9353
      @futrey9353 4 года назад

      Ip happesad mo we onze

  • @auerbacher69
    @auerbacher69 4 года назад

    you explained this better in six minutes than my professor in university did in the last three lectures.
    thanks.

  • @arimago
    @arimago 7 лет назад +3

    At 2:16, the text "0100111001100101011101100110010101110010001000000110011101101111011011100110111001100001001000000110011101101001011101100110010100100000011110010110111101110101001000000111010101110000001011000010000001101110011001010111011001100101011100100010000001100111011011110110111001101110011000010010000001101100011001010111010000100000011110010110111101110101001000000110010001101111011101110110111000001010010011100110010101110110011001010111001000100000011001110110111101101110011011100110000100100000011100100111010101101110001000000110000101110010011011110111010101101110011001000010000001100001011011100110010000100000011001000110010101110011011001010111001001110100001000000111100101101111011101010000101001001110011001010111011001100101011100100010000001100111011011110110111001101110011000010010000001101101011000010110101101100101001000000111100101101111011101010010000001100011011100100111100100101100001000000110111001100101011101100110010101110010001000000110011101101111011011100110111001100001001000000111001101100001011110010010000001100111011011110110111101100100011000100111100101100101000010100100111001100101011101100110010101110010001000000110011101101111011011100110111001100001001000000111010001100101011011000110110000100000011000010010000001101100011010010110010100100000011000010110111001100100001000000110100001110101011100100111010000100000011110010110111101110101" should've flown across the screen really fast, just to really drive the point home.

    • @haley9425
      @haley9425 2 года назад +2

      Its a rickroll...

  • @pacidraws3563
    @pacidraws3563 2 года назад

    "This series is called the basics, so, uh, deal with it" this is why i love your computer science videos

  • @cristinachiric7072
    @cristinachiric7072 7 лет назад +9

    I feel so smart now

  • @paulf1071
    @paulf1071 7 лет назад

    Love the subtle pixelation effect between time 0:46-0:50, demonstrating video compression codecs in operation!

  • @NoNameAtAll2
    @NoNameAtAll2 7 лет назад +5

    "You can't just lose a little but of detail, otherwise you'll end up sending wrong *worms* "
    Damn, that's clever

  • @malignusvonbottershnike563
    @malignusvonbottershnike563 4 года назад

    Just want to thank you for this video, because if I had taken a computer science exam this summer (cough cough COVID cough cough), this video would've been extremely helpful!

  • @gordonrichardson2972
    @gordonrichardson2972 7 лет назад +8

    A minor point: Position of atoms on a disk? More like magnetic fields.
    Edit: Nice visual stepping tree!

    • @PaleandPastey
      @PaleandPastey 7 лет назад +12

      The magnetic fields are defined by the orientation of electrons around the atoms of the disk; so it's 6 of one, half a dozen of the other really.

  • @Benny_Blue
    @Benny_Blue Год назад +1

    I always thought of Huffman Coding as “That learning tool from college I’ll never use practically,” but tonight I just discovered that the Jeopardy NES game used exactly this to compress all its questions and answers to a small enough size to fit on an NES cartridge. So learn this stuff! Sometimes it pops up when you least expect it!

  • @AndreiTache
    @AndreiTache 7 лет назад +5

    0:50 "...sending the wrong *worms* " I see what you did there =D

  • @conoroneill8067
    @conoroneill8067 7 лет назад

    An extra joke for those who watch with subtitles at 0:53, if anyone's interested. I love how Tom puts in that extra touch every here and there, even though most people probably wouldn't notice.

  • @jack9528
    @jack9528 7 лет назад +59

    But using the hauffman method, how does the computer separate the letters as long as they are in a constant stream?

    • @lcarusfp
      @lcarusfp 7 лет назад +17

      Let's imagine we have some "compression" tree and a string consisting of 10111010... . Every letter has an individual number assigned(the number is assigned with the tree). some are 4 digits long some are longer. So the computer sees the 1 and compares it with every assigned number. So the Pc checks 1-(every assigned number). If the result is zero it arrived at a letter. So the pc checks 1. No zero as result. Take the next bit 10. No 0 as result. Next bit 101. Still no zero as result. 1011 we get a zero as result. And display that letter. then we start again. 1. no zero as result .... Every letter has an individual path. So there will never be a letter assigned to 10111. that's how the pc knows when to seperate the string.

    • @MrMomoro123
      @MrMomoro123 7 лет назад +57

      It separates the letters by referencing the tree. As it gets 1s and 0s it goes down the tree until it hits a dead end. The letter at that dead end is what is outputted, and the program heads back to the top of the tree. The structure of the tree is how it knows where the breaks are.

    • @PregnantOrc
      @PregnantOrc 7 лет назад +12

      No branching point has a letter so if the point it comes to has a character instead of a branching path it has found the character needed and the next bit starts at the top of the tree.

    • @Spincervino
      @Spincervino 7 лет назад +17

      Look at the graph at 5:02
      Every time the computer reads a 1 it goes right in the tree, every time it reads a 0 it goes left. In this infinite sequence of zeros and ones, you only get to a letter at the end of a branch.
      You can imagine letters at the end of the branch as "leaves" in a tree, where every branch must end in one and only one leaf.
      The computer stores the entire tree so it knows if the sequence has reached a leaf or if it is still on a branch.
      If, with the last bit read, you did not get to a letter (end of branch) you continue reading. If you got to a letter, write the letter and start a new one.

    • @CoolJosh3k
      @CoolJosh3k 7 лет назад +4

      Giacomo 3003 it knows because it reached the end of a branch.

  • @tushar8133a
    @tushar8133a 7 лет назад

    I believe you look much more confident in compare to your previous videos, and also I wasn't expecting that your video will be so hypnotically extremely understandable; but you just nailed it. Thanks for sharing!

  • @Hdtjdjbszh
    @Hdtjdjbszh 7 лет назад +5

    THAT DAMN WORM PUN!

  • @GtaRockt
    @GtaRockt 7 лет назад

    I know about this stuff already but still watch it because Tom Scott is a good lad

  • @tylermassey5431
    @tylermassey5431 7 лет назад +4

    "The wrong worms" I see what you did there... nice.

  • @Mickster2233
    @Mickster2233 7 лет назад

    Marvelous imagery! If it weren't for the intuitive visuals and your keen explanation, I would have never understood this. This is fascinating once you get it!

  • @ForboJack
    @ForboJack 5 лет назад +4

    Tom Scott: Text has to be losslessly compressed!
    Xerox: Hold my copy machine!!!

  • @Niendorf_an_der_Stecknitz
    @Niendorf_an_der_Stecknitz 2 года назад

    I never expected that I'd to watch Tom Scott videos for my exams, yet, here I am.

  • @jainamshah44970
    @jainamshah44970 3 года назад +5

    Those here for Cryptocracy :)

  • @jackshears2043
    @jackshears2043 5 лет назад +1

    2 computer science lesson now make sense after 6:30 of of Tom Scott explaining Huffman Code! Thank you

  • @boredphysicist
    @boredphysicist 5 лет назад +3

    Shame modern game devs have given up on saving space and increasing efficiency. Brute force is now the solution.

    • @marcusborderlands6177
      @marcusborderlands6177 4 года назад +2

      The issue is that people are getting higher resolution displays, needing higher resolution textures, and games are using less repeating textures to make each location feel unique.

  • @MikeRees
    @MikeRees 7 лет назад

    This takes me back to uni, heh. I'd actually forgotten everything about Huffman Coding except how it looks and its purpose. Cheers!

  • @Grendelmk1
    @Grendelmk1 2 года назад +3

    Did he actually say "you end up sending the wrong worms"?

  • @justinhadley3927
    @justinhadley3927 7 лет назад +1

    Tom Scott, you are the definitive ´Elder of the Internet´.

  • @Motorman2112
    @Motorman2112 7 лет назад +3

    1:08, no animated sunglasses? Disappointed.

  • @diddeldudellduh
    @diddeldudellduh 2 года назад

    I can't believe how far computer monitor design has come since this video was filmed back in 2017!

  • @megamegacoolman
    @megamegacoolman 7 лет назад +33

    "Otherwise you end up sending the wrong worms"

    • @harrietgriffiths5002
      @harrietgriffiths5002 7 лет назад +10

      Blah Cga it means "sending the wrong *words*" but he sent the wrong word so it says "worms"

  • @renakunisaki
    @renakunisaki 6 лет назад

    Great summary.
    This method is also combined with LZ ("repeat 6 characters starting 8 back from the one you just decoded") and RLE ("repeat this character 5 times"). As far as I know those plus Huffman are the fundamentals of every compression algorithm.

  • @0VexRoblox
    @0VexRoblox 2 года назад +5

    3:32 well that aged like milk.

  • @larrylentini5688
    @larrylentini5688 7 лет назад +2

    Thanks to this channel I know the solutions to so many problems I didn't previously know existed. Thank you?

  • @timtjtim
    @timtjtim 7 лет назад +66

    The wrong "worms", that certainly makes up for the Quadrillion / Trillion mistake!
    Edit: As I typed that, my grammar checker tried to suggest it should be "words"!

    • @Yeldur
      @Yeldur 7 лет назад +2

      It's a play on words; or rather, characters. Tom was supposed to say "The wrong words" but instead replaced a single character to represent the incorrect character being sent.

    • @DarkYuan
      @DarkYuan 7 лет назад

      On that tangent, perhaps a video explaining how spell-checkers work? I think it had something to do with binary search trees, which I only briefly covered in college.

    • @f4tornado450
      @f4tornado450 6 лет назад

      A quadrillion bits is actually 125 gigabytes, so I wouldn't consider it a mistake