IUHI87

Click Here to Download this Answer Instantly

ECS 32B

1. Implement the level order tree traversal algorithm that we discussed briefly in class (see the slides for lecture 19). Name your function levelorder. Assume that your function expects one argument, a binary tree represented in the nodes and references form described in the “Nodes and References” section of Chapter 6. (That would be section 6.4.2 for those who have the paper version of the textbook.) When your function processes a node (see “process the node” in the “Level order traversal” slide), your function should just print the key for that node. So, for example, if we test your function with the binary tree drawn in the “Level order traversal” slide,

your function should print “ABCDEFGHIJ”.

You will want to construct some binary trees so that you can test your function. use the code in the “Nodes and References” section for that purpose. Do not include that code in your “hw4.py” file. We just want your levelorder function and any supporting functions you create.