Hello,
I have been doing a project of Huffman encoding/decoding.
The program receives input, counts the character frequency, then makes the Huffman tree.
After I build the tree, I don't know how to traverse all the tree from the root to every leaf to make the code table.

for example, let's consider this input: "SUSIE SAYS IT IS EASY"
frequency table:
Character freq
A 2
E 2
I 3
S 6
T 1
U 1
Y 2
Space 4
Linefeed 1

Huffman tree: sp: space; lf: line feed; * means no character

-----------------------*, 22----------------------
-----*, 9------- -----*, 13----
sp, 4 ----*, 5--------- S, 6 ----- *, 7------
A, 2 ------*, 3------ I, 3 -----*, 4----
T, 1 -----*, 2---- Y, 2 E, 2
lf, 1 U, 1


Now, I need to traverse all the tree from the root to every leaf to make the code table. When turn left, '0' will be recorded and '1' for turning right. It means I must have the code table like:
Character Code
A 010
E 1111
I 110
S 10
T 0110
U 01111
Y 1110
Space 00
Linefeed 01110

The problem is, I don't know how to write the code to traverse the tree.
Do you guys have any idea?