public class PQ4
extends java.lang.Object
Constructor and Description |
---|
PQ4() |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
buildTree(char[] letters)
Add letters to ternary tree using a level-order traversal (breadth first search).
|
static void |
main(java.lang.String[] args) |
(package private) static void |
printTree(Node current,
java.lang.String answer)
Traverse the tree using recursion and print the letters contained in
every path from the root to a leaf node.
|
static Node root
public static void main(java.lang.String[] args)
static void buildTree(char[] letters)
Take a moment to look over the setup code and implement the while loop.
Queue
and assign it into a temporary variable
char[] letters
will always contain i * 3 + 1
letters.letters
- an array of lettersstatic void printTree(Node current, java.lang.String answer)
Follow this algorithm:
current
- a reference to the tree nodeanswer
- a string