Huffman coding step-by-step example

Поділитися
Вставка
  • Опубліковано 26 гру 2024

КОМЕНТАРІ • 101

  • @Aaliyah1909
    @Aaliyah1909 Рік тому +72

    5 minutes and you taught me more then my own lectures could, you kept in concise unlike other videos, straight to the point and very well worded. I thank you highly!!

  • @w花b
    @w花b Рік тому +22

    Just 5 minutes to understand that. Couldn't be more concise. Great job

  • @Hirozachi
    @Hirozachi 3 роки тому +103

    i've been watching many videos explaining this lesson but couldn't understand it because they always miss the point that i should move the bigger value to the left, i have a final exam after 4 days and now i'm ready for it because of you, thank you so much.

    • @mikhailwebb8377
      @mikhailwebb8377 Рік тому +1

      how did the exam went?

    • @sahitdodda5046
      @sahitdodda5046 8 місяців тому +9

      ​@@mikhailwebb8377not well for them, the convention is to have the bigger value on the right, NOT the left. The video gets it wrong

    • @rit0838
      @rit0838 Місяць тому

      @@sahitdodda5046 This is wrong. Huffman trees do not care about if the bigger value is right or left, both solutions are correct.

  • @jackc7475
    @jackc7475 2 роки тому +14

    Perfect video, with clear concise demonstration, fully helped me understand Huffman coding, thank you

  • @xfxdedfade6387
    @xfxdedfade6387 11 місяців тому +3

    This was so concise, I have a presentation tomorrow and this saved me, thank you.

  • @christio02
    @christio02 Рік тому +2

    Thank you! You explained better than a 3 hour lecture did

  • @mattels
    @mattels Рік тому +5

    Amazing Video, I spent maybe an hour trying other videos to understand this, but somehow you managed in just under 5 minutes.

  • @MoguMogu818
    @MoguMogu818 8 місяців тому +5

    I had a two hour lab on Huffman coding and couldn't understand shit. This taught me instantly when you mentioned "priority queue".

    • @damarisgoumtsop6319
      @damarisgoumtsop6319 7 місяців тому

      what school you going to if i may ask ?. I've the same lab lol

    • @impanthering
      @impanthering 2 місяці тому

      @@damarisgoumtsop6319 what bout you

  • @boredguy5805
    @boredguy5805 Рік тому +67

    I failed my quiz because of this video, should have read the comments first. Everyone be warned, the lower frequency number must always be on the left, not the right, this is not something he practices in this video.
    Where he goes wrong is that he sorts from highest frequency to lowest in the queue, when it should be the opposite

    • @glitterfart
      @glitterfart Рік тому +3

      Thanks man, have a test tomorrow.

    • @oguzhanalasulu5678
      @oguzhanalasulu5678 7 місяців тому +5

      I also realized it. Thanks for feedback about this situation, bud!

    • @jonatahnelhadad7430
      @jonatahnelhadad7430 7 місяців тому +1

      i also failed my question i came back after failing and sadly only now i noticed your comment...

    • @liam_iam
      @liam_iam 7 місяців тому +7

      it doesn't matter which way you visualise the queue (left/right), it matters which side you take the elements out of the queue (you should be taking the lowest frequency elements). I don't think the video creator is at fault for this.

    • @YitzhakPrince-Isaac
      @YitzhakPrince-Isaac 4 місяці тому

      Yeah cuz I was like somethings wrong here had to browse the web for minutes thanks tho!!

  • @kamalkishor1493
    @kamalkishor1493 Рік тому +1

    Brother, You are tremendous... I Love the way you explained!!

  • @dider
    @dider Рік тому +6

    This is how to decode properly:
    1. Take a bit from the encoded string.
    2. Start at the root of the tree.
    3. Follow the edge denoted by that bit value to the adjacent node.
    4. If the node is a leaf, then return the corresponding character.
    5. Otherwise take the next bit from the encoded string and continue following down the tree until a leaf node is found.
    Example:
    1. Start with the first bit in the encoded string, which is 1.
    2. Start at the root of the tree.
    3. The root is obviously not a leaf, so follow the edge marked 1 and we reach the leaf node, which is ''A'.
    4. Then take the next bit, which is also 1. So, follow the step 3 above and return 'A' again.
    5. Then take the next bit, which is 0 and start at the root again.
    6. The edge 0 from the root leads to a non-leaf node (marked 4).
    7. So, take the next bit from the encoded string, which is also 0 and continue following from the last node where we were at in the last step (which is the non-leaf node 4).
    8. If we follow the edge 0, we reach a leaf node denoting character 'B'.
    9. And so on..
    The important point is every time we find a character, we take the next bit from the encoded string and start at the root of the tree.

    • @badbanana2547
      @badbanana2547 9 місяців тому

      Thank you! I read through all the comments looking for this specific thing

  • @dankmemes3447
    @dankmemes3447 5 місяців тому

    5 minutes and i understood it! thanks for saving my bachelors for now

  • @Connapasko
    @Connapasko 8 місяців тому +1

    this broke my brain in college and somehow you made it so clear in

  • @MagnificientLlama
    @MagnificientLlama Рік тому +1

    You sir are wonderful help for my finals preparation

  • @alexl5010
    @alexl5010 26 днів тому

    Astonishing explanation, thank you!

  • @a96futurecreator96
    @a96futurecreator96 Рік тому +4

    2:15 why is 4 at left side of 3 (node a3), I thought everything bigger than the node should go to the right side.

    • @kamalkishor1493
      @kamalkishor1493 Рік тому +1

      In very first step, You have to decide where you want to put the element. Either on left or right side.

    • @baraa2459
      @baraa2459 7 місяців тому

      True, it was a mistake i think and few people noticed it !!!!!

  • @vishwajeet5051
    @vishwajeet5051 Рік тому +1

    this was just what i was searching for

  • @rygerety8384
    @rygerety8384 3 роки тому +1

    Was searching through this and found this video... I had completely forgotten that u had made a vid on this

  • @stawrstudent
    @stawrstudent 6 днів тому

    Do you have to put the A3 or each last part on the right?

  • @FoxGlove8
    @FoxGlove8 4 місяці тому

    How would it work if there were more symbols to account for? And then there would be I, and II in the same algorithm. How would we know to differentiate between 2 I or 1 II? Hope I'm making some sense!

  • @Backflipmarine
    @Backflipmarine 4 роки тому +4

    thanks for the vid, also learnt 5678 (56=7*8), easy way to remember

  • @ll647
    @ll647 26 днів тому +1

    This explanation works. Thx

  • @MultiBlack132
    @MultiBlack132 2 місяці тому

    thx you mate you saved me A LOT OF TIME liked the video

  • @marianosalcedo3803
    @marianosalcedo3803 Рік тому +1

    You explained this so well, thank you

  • @SpacePunk1000
    @SpacePunk1000 7 місяців тому

    at 1:38 B and 2 are equal so does it matter which you put first? Could you put A then 2 then B?

  • @princeofexcess
    @princeofexcess 6 місяців тому

    when sending on the network you also have to send the tree to decode it on the other side. So i doesnt pay of for short strings.

  • @rokiatousidibe1292
    @rokiatousidibe1292 Місяць тому

    I just have a question about the decoding part, how do we identify the code without the spaces ?

    • @AleksandrStrizhevskiy
      @AleksandrStrizhevskiy 18 днів тому

      The space key is also an ascii code. So you can include spaces as part of your encoding, or try to guess where the space should be, if the code is in a natural language you understand.

  • @melihcanyldz368
    @melihcanyldz368 Рік тому +5

    I think this answer is wrong because of that we need to write the small number to the left side of the tree . you have done the opposite . I mentioned the 2:02

    • @baraa2459
      @baraa2459 7 місяців тому

      True, thank you for noticing
      I thought my lectures were wrong 😂

  • @staa6589
    @staa6589 6 місяців тому +1

    thank you very much, very nice explanation

  • @TimnitAsamnew
    @TimnitAsamnew 10 місяців тому +1

    i did not get why you write A3 on the right side

    • @sat_this_h
      @sat_this_h 10 місяців тому +1

      Yes, I think it should be on the left since it's smaller than 4

    • @Ahmedibrahim-xv1je
      @Ahmedibrahim-xv1je 9 місяців тому +1

      Should be on left

  • @tiradeee
    @tiradeee 3 роки тому +2

    i have my paper 2 FINAL gcse exam tomorrow, so one question: where u put the binary, is it ALWAYS 0 on the left and 1 on the right?

  • @hoki8296
    @hoki8296 Рік тому +1

    It was really helpful. Thank you

  • @Yureka-ox5jn
    @Yureka-ox5jn 9 місяців тому

    What about the codes to decode? Are they also transferred with the file?

  • @douggale5962
    @douggale5962 8 місяців тому

    This cheats a little bit though - how does the decoder side magically know the Huffman tree? In actual practice, the part that sometimes needs a ton of cleverness is compactly encoding the tree into the output. Sometimes you can get away with a hard-coded tree that works well most of the time.

  • @arnabsen8633
    @arnabsen8633 15 годин тому

    precise..well done

  • @sunilbrevannavar1379
    @sunilbrevannavar1379 5 місяців тому

    how does one break the tie of frequencies , alphabetical order?

    • @AleksandrStrizhevskiy
      @AleksandrStrizhevskiy 18 днів тому +1

      Its important that you encode and decode the same way. Ideally you would have the full tree to transfer to a decoder. However, a professor did give us a task to decode a binary string and we were supposed to work backwards to figure out the tree and decode it. You should know that this is not the practical way in which this is used. Funny enough, the professor got the code from some website probably (GeeksForGeeks) and they did the encoding differently from the way he taught us so we couldnt get the answer and the professor apologized and said he would just give us points for it. If you have to decode, you just have to take a guess how the professor did it (alphabetical order makes sense), and if he marks you wrong argue that you did it correctly, but had a different approach.

  • @yasmineguemri
    @yasmineguemri 6 місяців тому +1

    amazing video! thanks !!

  • @matansavage
    @matansavage 3 місяці тому +1

    amazing tutorial thanks

  • @mr.zafner8295
    @mr.zafner8295 Рік тому +1

    What an excellent explanation. Thank you so much

  • @jabirhaleem3495
    @jabirhaleem3495 Місяць тому

    isnt it 8 bits for a character?

  • @rummanchowdhury3807
    @rummanchowdhury3807 2 роки тому +1

    Great succinct explanation!

  • @nc737
    @nc737 7 місяців тому

    The decoding is not really explained by this -> how do we know to decode only 1 bit, from 1 to A vs 2 bits from 11 -> whatever

  • @galbalandroid
    @galbalandroid 2 роки тому +1

    what to do if our tree (in the progress of building it) is for example 3 and we have 2 options 2 and 2.5 for example?

  • @giraysekerlen5150
    @giraysekerlen5150 3 місяці тому +1

    I would appreciate this even more if you had mentioned the property of prefix-free codes. otherwise, one could get confused about how to determine where one code ends and the next one begins.

    • @giraysekerlen5150
      @giraysekerlen5150 3 місяці тому +1

      still, that's hell of a job the way you explained it, thank you so much!

  • @albaraa-bin-malek
    @albaraa-bin-malek 4 місяці тому

    The node with value 4 should be on the right side instead of A3 because it has a larger value. So, node with value 7 has left child of A3 and right child of 4

  • @sohaibtraidi4766
    @sohaibtraidi4766 2 місяці тому

    I guess the smaller should be on the left ?

  • @Hustlers_hab
    @Hustlers_hab 11 місяців тому

    enjoying the beat.

  • @Timmy-oo2vx
    @Timmy-oo2vx Рік тому

    really good vdo I recommend this

  • @leoliang1
    @leoliang1 Рік тому +1

    Hey your huffman tree is backwards. The smaller ones should go on the left

  • @rain_yy
    @rain_yy 8 місяців тому +1

    Thank you!

  • @mikolobabz
    @mikolobabz Рік тому +2

    The background music is intruding

  • @PaulG106
    @PaulG106 2 роки тому +2

    Wow! Thank you!!

  • @LugiPaule
    @LugiPaule 8 місяців тому

    great video bro

  • @305killer
    @305killer 7 днів тому +1

    ez finals thanks to you

  • @victoralvarez9601
    @victoralvarez9601 7 місяців тому

    whats the song in the background?

  • @caitlinn3455
    @caitlinn3455 3 роки тому +1

    thank you

  • @JeezVince
    @JeezVince 2 роки тому

    excellent

  • @arunimachakraborty1175
    @arunimachakraborty1175 Рік тому

    Thanks a lot!

  • @MB31TheG
    @MB31TheG 2 роки тому

    genius , thank you

  • @kavz22
    @kavz22 Місяць тому

    thanks:)

  • @HighlandCatz
    @HighlandCatz Рік тому

    thanks

  • @GoodNewsJim
    @GoodNewsJim 3 роки тому

    I actually understand how this works now... I just wonder... about those... like extra... those non usable extra bits people chuck out... Like... You think they could be used for extraneous packing somehow? Hmmmm. I dunno, this is good enough.
    You explained in a few seconds(knew where to fast forward) where profs you tube videos couldn't

    • @vampire_catgirl
      @vampire_catgirl 3 роки тому +1

      I don't think so, if you made them do anything then whatever code you use to decompress wouldn't know to keep going for a letter

  • @StracheyLou-h3e
    @StracheyLou-h3e 3 місяці тому

    Cleora Mission

  • @kacperkwasny3848
    @kacperkwasny3848 6 місяців тому

    ktos kik?

  • @homeopathicfossil-fuels4789
    @homeopathicfossil-fuels4789 3 місяці тому

    Yeah but where would you store the tree structure? That is still ambivalent to me, without the tree you cant figure out what is what
    oh wait I get it, its like any other thing where the table is generated instead of static, you store the table, or at least enough information to generate it
    alright there we go
    thank you!!!!!!

  • @RuthDillard-b4b
    @RuthDillard-b4b 3 місяці тому

    Douglas Wall

  • @alessandrolobosco7686
    @alessandrolobosco7686 11 місяців тому +9

    This tutorial is totally wrong :)

    • @alessandrolobosco7686
      @alessandrolobosco7686 11 місяців тому +9

      1- You have to use a priority queue.
      2- IF a number is bigger you have to put this number in the right of the tree, if is smaller in the left, you are giving wrong informations.
      Please, delete this video and make the correct video. 😁

  • @pixie_laluna
    @pixie_laluna Місяць тому

    I got confused watching the video. The I read the comment section and read so many people failed their exams because of this video. Just wow.

  • @BrightCherry-e8b
    @BrightCherry-e8b 3 місяці тому

    Jabari Estates

  • @ahmetsahin1147
    @ahmetsahin1147 7 місяців тому

    i have orgazm watching this

  • @AlphyCabante
    @AlphyCabante Рік тому +2

    this is wrong the answer is A= 0 b= 10 c=110 d=111

    • @ickebins6948
      @ickebins6948 9 місяців тому

      No, if you change the A to the left side (0) you have to switch the whole tree.
      The pattern of left = 0 & right = 1, has to be the same for the whole tree.

  • @lowlife5011
    @lowlife5011 Рік тому

    W video

  • @BloodTonyPeriod
    @BloodTonyPeriod 7 місяців тому

    bro does NOT know what hes doing