Question: 3) Write an application program a3q4.cpp that e contains a create binary treefunction which create the following binary tree (refer to lab 6 exercise click

 3) Write an application program a3q4.cpp that e contains a create

3) Write an application program a3q4.cpp that e contains a create binary treefunction which create the following binary tree (refer to lab 6 exercise click the link) contains main () function which call create binary tree () function to create a binary tree, and then call preorder and breadth_first functions to print the nodes in preorder and level order, respectively Five files should be submitted for this program question. 1) the stack and queue class templates Stack.h and Queue.h, 2) the file funcs.cpp which contains the implementation of functions, 3) the application file a3q4.cpp containing main() function, 4)a script file a3q4result containing result. Here are the sample runs The preorder: A B D G ICE H J K F The level order: A B C DE F G HI J K Hint: The non-recursive preorder traversal uses a stack to store the nodes of the tree. First push the root of the tree in the stack. Then use a while loop: if the stack of nodes is not empty, visit the element of the node at the top position, pop the node, and push the right child and left child of the node. Repeat until the stack is empty The level-order traversal uses a queue to store the nodes of the tree. First enqueue the root of the tree in the queue. Then use a while loop: i the queue of nodes is not empty, visit the element of the node at the queue front, enqueue the left child and right child of the node. And then dequeue the node. Repeat until the queue is empty

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!