|All-time Popular Problems|
|Check if subtree|
|Delete Middle of Linked List|
|Given a linked list of 0s, 1s and 2s, sort it.|
|Count nodes of linked list|
|Delete N nodes after M nodes of a linked list|
|Check for Balanced Tree|
|Remove every k'th node|
|k largest elements|
|0 - 1 Knapsack Problem|
|Subarray with given sum|
Given An array of Alphabets and their frequency. Your task is to print all the given alphabets Huffman Encoding.
Note: If two elements have same frequency, then the element which if at first will be taken on left of Binary Tree and other one to right.
First line consists of test cases T. First line of every test case consists of string of alphabets and second line consists of its frequencies.
Print the HuffmanCodes in single line, with n spaces of each alphabet's HuffmanCodes respectively. In PreOrder form of Binary Tree.
5 9 12 13 16 45
0 100 101 1100 1101 111
For the above test case.
HuffmanCodes will be
Print in the PreOrder of Binary Tree.