Huffman coding step-by-step example

  Рет қаралды 154,116

Pizzey Technology

Pizzey Technology

Күн бұрын

Another example for my students learning Huffman coding. In this video I show you how to build a Huffman tree to code and decode text.

Пікірлер: 84
@Aaliyah1909
@Aaliyah1909 9 ай бұрын
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!!
@Lerieal
@Lerieal 2 жыл бұрын
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 10 ай бұрын
how did the exam went?
@sahitdodda5046
@sahitdodda5046 5 ай бұрын
​@@mikhailwebb8377not well for them, the convention is to have the bigger value on the right, NOT the left. The video gets it wrong
@MoguMogu818
@MoguMogu818 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 4 ай бұрын
what school you going to if i may ask ?. I've the same lab lol
@mattels
@mattels Жыл бұрын
Amazing Video, I spent maybe an hour trying other videos to understand this, but somehow you managed in just under 5 minutes.
@dider
@dider 9 ай бұрын
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 6 ай бұрын
Thank you! I read through all the comments looking for this specific thing
@kamalkishor1493
@kamalkishor1493 10 ай бұрын
Brother, You are tremendous... I Love the way you explained!!
@Connapasko
@Connapasko 5 ай бұрын
this broke my brain in college and somehow you made it so clear in
@rygerety8384
@rygerety8384 2 жыл бұрын
Was searching through this and found this video... I had completely forgotten that u had made a vid on this
@MagnificientLlama
@MagnificientLlama Жыл бұрын
You sir are wonderful help for my finals preparation
@dankmemes3447
@dankmemes3447 2 ай бұрын
5 minutes and i understood it! thanks for saving my bachelors for now
@Backflipmarine
@Backflipmarine 3 жыл бұрын
thanks for the vid, also learnt 5678 (56=7*8), easy way to remember
@a96futurecreator96
@a96futurecreator96 Жыл бұрын
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 10 ай бұрын
In very first step, You have to decide where you want to put the element. Either on left or right side.
@baraa2459
@baraa2459 4 ай бұрын
True, it was a mistake i think and few people noticed it !!!!!
@vishwajeet5051
@vishwajeet5051 11 ай бұрын
this was just what i was searching for
@princeofexcess
@princeofexcess 3 ай бұрын
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.
@TimnitAsamnew
@TimnitAsamnew 7 ай бұрын
i did not get why you write A3 on the right side
@sat_this_h
@sat_this_h 7 ай бұрын
Yes, I think it should be on the left since it's smaller than 4
@Ahmedibrahim-xv1je
@Ahmedibrahim-xv1je 6 ай бұрын
Should be on left
@marianosalcedo3803
@marianosalcedo3803 Жыл бұрын
You explained this so well, thank you
@douggale5962
@douggale5962 5 ай бұрын
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.
@SpacePunk1000
@SpacePunk1000 4 ай бұрын
at 1:38 B and 2 are equal so does it matter which you put first? Could you put A then 2 then B?
@victoralvarez9601
@victoralvarez9601 4 ай бұрын
whats the song in the background?
@Yureka-ox5jn
@Yureka-ox5jn 6 ай бұрын
What about the codes to decode? Are they also transferred with the file?
@rummanchowdhury3807
@rummanchowdhury3807 Жыл бұрын
Great succinct explanation!
@hoki8296
@hoki8296 Жыл бұрын
It was really helpful. Thank you
@yasmineguemri
@yasmineguemri 3 ай бұрын
amazing video! thanks !!
@mr.zafner8295
@mr.zafner8295 11 ай бұрын
What an excellent explanation. Thank you so much
@PizzeyTechnology
@PizzeyTechnology 11 ай бұрын
Glad it was helpful!
@nc737
@nc737 4 ай бұрын
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
@PaulG106
@PaulG106 2 жыл бұрын
Wow! Thank you!!
@PizzeyTechnology
@PizzeyTechnology 2 жыл бұрын
Welcome!
@mikebabz
@mikebabz Жыл бұрын
The background music is intruding
@LugiPaule
@LugiPaule 5 ай бұрын
great video bro
@rain_yy
@rain_yy 5 ай бұрын
Thank you!
@Timmy-oo2vx
@Timmy-oo2vx Жыл бұрын
really good vdo I recommend this
@galbalandroid
@galbalandroid 2 жыл бұрын
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?
@JeezVince
@JeezVince Жыл бұрын
excellent
@arunimachakraborty1175
@arunimachakraborty1175 Жыл бұрын
Thanks a lot!
@HighlandCatz
@HighlandCatz Жыл бұрын
thanks
@RuthDillard-b4b
@RuthDillard-b4b 17 күн бұрын
Douglas Wall
@kacperkwasny3848
@kacperkwasny3848 3 ай бұрын
ktos kik?
@alessandrolobosco7686
@alessandrolobosco7686 8 ай бұрын
This tutorial is totally wrong :)
@alessandrolobosco7686
@alessandrolobosco7686 8 ай бұрын
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. 😁
@ahmetsahin1147
@ahmetsahin1147 4 ай бұрын
i have orgazm watching this
@BloodTonyPeriod
@BloodTonyPeriod 4 ай бұрын
bro does NOT know what hes doing
@boredguy5805
@boredguy5805 Жыл бұрын
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 11 ай бұрын
Thanks man, have a test tomorrow.
@oguzhanalasulu5678
@oguzhanalasulu5678 4 ай бұрын
I also realized it. Thanks for feedback about this situation, bud!
@jonatahnelhadad7430
@jonatahnelhadad7430 4 ай бұрын
i also failed my question i came back after failing and sadly only now i noticed your comment...
@liam_iam
@liam_iam 4 ай бұрын
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 Ай бұрын
Yeah cuz I was like somethings wrong here had to browse the web for minutes thanks tho!!
@w花b
@w花b 9 ай бұрын
Just 5 minutes to understand that. Couldn't be more concise. Great job
@jackc7475
@jackc7475 Жыл бұрын
Perfect video, with clear concise demonstration, fully helped me understand Huffman coding, thank you
@melihcanyldz368
@melihcanyldz368 Жыл бұрын
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 4 ай бұрын
True, thank you for noticing I thought my lectures were wrong 😂
@giraysekerlen5150
@giraysekerlen5150 Күн бұрын
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 Күн бұрын
still, that's hell of a job the way you explained it, thank you so much!
@sunilbrevannavar1379
@sunilbrevannavar1379 2 ай бұрын
how does one break the tie of frequencies , alphabetical order?
@matansavage
@matansavage 24 күн бұрын
amazing tutorial thanks
@xfxdedfade6387
@xfxdedfade6387 8 ай бұрын
This was so concise, I have a presentation tomorrow and this saved me, thank you.
@tiradeee
@tiradeee 3 жыл бұрын
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?
@rygerety8384
@rygerety8384 2 жыл бұрын
Not always, but usually
@FoxGlove8
@FoxGlove8 Ай бұрын
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!
@homeopathicfossil-fuels4789
@homeopathicfossil-fuels4789 28 күн бұрын
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!!!!!!
@leoliang1
@leoliang1 10 ай бұрын
Hey your huffman tree is backwards. The smaller ones should go on the left
@البراءبنمالك-ر1م
@البراءبنمالك-ر1م Ай бұрын
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
@staa6589
@staa6589 3 ай бұрын
thank you very much, very nice explanation
@christio02
@christio02 9 ай бұрын
Thank you! You explained better than a 3 hour lecture did
@BrightCherry-e8b
@BrightCherry-e8b 5 күн бұрын
Jabari Estates
@StracheyLou-h3e
@StracheyLou-h3e 24 күн бұрын
Cleora Mission
@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 2 жыл бұрын
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
@Hustlers_hab
@Hustlers_hab 8 ай бұрын
enjoying the beat.
@caitlinn3455
@caitlinn3455 3 жыл бұрын
thank you
@PizzeyTechnology
@PizzeyTechnology 3 жыл бұрын
You're welcome
@AlphyCabante
@AlphyCabante Жыл бұрын
this is wrong the answer is A= 0 b= 10 c=110 d=111
@ickebins6948
@ickebins6948 6 ай бұрын
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.
@MB31TheG
@MB31TheG Жыл бұрын
genius , thank you
@lowlife5011
@lowlife5011 Жыл бұрын
W video
Huffman Codes: An Information Theory Perspective
29:11
Reducible
Рет қаралды 230 М.
3.4 Huffman Coding - Greedy Method
17:44
Abdul Bari
Рет қаралды 1,6 МЛН
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 124 МЛН
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
But what are Hamming codes? The origin of error correction
20:05
3Blue1Brown
Рет қаралды 2,4 МЛН
Compressing text using Huffman trees worked example
15:48
Mr Dimmick's Computing Channel
Рет қаралды 37 М.
Der Huffman Code | Algorithmen und Datenstrukturen
6:12
Florian Dalwigk
Рет қаралды 68 М.
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 40 МЛН
Huffman Encoding
17:36
Lalitha Natraj
Рет қаралды 31 М.
How Huffman Trees Work - Computerphile
11:07
Computerphile
Рет қаралды 252 М.
How are Images Compressed?  [46MB ↘↘ 4.07MB] JPEG In Depth
18:47
Branch Education
Рет қаралды 3,5 МЛН
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,3 МЛН