Skip to main content
Lesson 39 - Queues
ZIPPDF (letter)
Lesson MenuPreviousNext
  
L.A.39.1 - PrintByLevel page 7 of 8

Background:

  1. 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:

  1. Use the ListQueue class to provide the necessary queue routines for this lab exercise.

  2. 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.

  3. 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:

  1. 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.

  2. Turn in your source code and the two run outputs.


Lesson MenuPreviousNext
Contact
 ©ICT 2003, All Rights Reserved.