| 1 | [('a',5), ('b',9), ('c',12), ('d',13), ('e',16), ('f',45)] | Build min-heap | [ ] | [('a',5), ('b',9), ('c',12), ('d',13), ('e',16), ('f',45)] |
| 2 | [('a',5), ('b',9), ('c',12), ('d',13), ('e',16), ('f',45)] | Pop two smallest | ('a',5) and ('b',9) | [('c',12), ('d',13), ('e',16), ('f',45)] |
| 3 | [('c',12), ('d',13), ('e',16), ('f',45)] | Create merged node | Node(freq=14) with children 'a' and 'b' | [('c',12), ('d',13), ('e',16), ('f',45), ('ab',14)] |
| 4 | [('c',12), ('d',13), ('e',16), ('f',45), ('ab',14)] | Pop two smallest | ('c',12) and ('d',13) | [('e',16), ('f',45), ('ab',14)] |
| 5 | [('e',16), ('f',45), ('ab',14)] | Create merged node | Node(freq=25) with children 'c' and 'd' | [('e',16), ('f',45), ('ab',14), ('cd',25)] |
| 6 | [('e',16), ('f',45), ('ab',14), ('cd',25)] | Pop two smallest | ('ab',14) and ('e',16) | [('f',45), ('cd',25)] |
| 7 | [('f',45), ('cd',25)] | Create merged node | Node(freq=30) with children 'ab' and 'e' | [('f',45), ('cde',30)] |
| 8 | [('f',45), ('cde',30)] | Pop two smallest | ('cde',30) and ('f',45) | [ ] |
| 9 | [ ] | Create merged node | Node(freq=75) with children 'cde' and 'f' | [('abcdef',75)] |
| 10 | [('abcdef',75)] | Heap size 1, stop | [ ] | [('abcdef',75)] |