3 votes 3 votes In huffman coding how to know whether we should designate left child as 0 and right as 1 or vice versa..?? Algorithms huffman-code algorithms sequence-series + – iita asked Dec 31, 2016 • retagged Jun 23, 2022 by makhdoom ghaya iita 12.3k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Anup patel commented Dec 31, 2016 reply Follow Share By default we consider left as 0 if Not mentioned. 1 votes 1 votes raja11sep commented Oct 15, 2020 reply Follow Share The answer will be 101. 66 / \ 27 39 / \ / \ 12 15 19 20 / \ / \ 7 8 9 10 / \ 4 5 step 1 : 4 + 5=9 step 2: 7 + 8=15 step 3: 9+10=19 step 4: 12 + 15=27 step 5: 19+20=39 step 6: 27+39=66 Note: At each step take minimum two elements from priority_queue(Or min_heap()) then add them and push again into the heap.continue:) 0 votes 0 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes Binary code of m5 is 110 Deepak Yadav answered Dec 31, 2016 • selected Dec 31, 2016 by focus _GATE Deepak Yadav comment Share Follow See all 4 Comments See all 4 4 Comments reply iita commented Jan 1, 2017 reply Follow Share they have given 001..how would you know whether which way to put 0's and 1's...??? logically both are correct but still what is the default case 0 votes 0 votes Deepak Yadav commented Jan 1, 2017 reply Follow Share Default case is left child 0 and right child 1. 0 votes 0 votes iita commented Jan 1, 2017 reply Follow Share but u have taken the children towards left it should be on right...isn't it..? 0 votes 0 votes Deepak Yadav commented Jan 2, 2017 reply Follow Share In above tree , always we take two minimum and add them afterwards we take next no. If no. Is less then we make left child otherwise right child. . I hope you will understand. 0 votes 0 votes Please log in or register to add a comment.