| |
L.A.39.1 - PrintByLevel | page 7 of 8 |
Background:
A different kind of binary tree traversal scheme is to visit the nodes level by level. Your task in this lab exercise is to print out a binary tree by level from left to right. For example, this binary tree of letters will result in the following output of letters:

M E R A J P T G N Q X H
Assignment:
Use the ListQueue class to provide the necessary queue routines for this lab exercise.
Starting with the earlier binary tree lab exercise in Lesson 37, L.A.37.1, TreeStats, build a binary tree of characters ordered by letter.
Write a method printLevel that prints out the tree, level by level from left to right. The output can be formatted in one line as in the above example.
Instructions:
Use the same data files (fileA.txt) and (fileB.txt) as in the earlier binary tree lab in Lesson 37, L.A.37.1, TreeStats.
Turn in your source code and the two run outputs.
|