Question: Problem statement: C + + Language In this assignment you will write a code to read in a tree in the adjacency matrix format and

Problem statement: C++ Language
In this assignment you will write a code to read in a tree in the adjacency matrix format and then print the pre-order, in-order and post-order traversals of the same. For the trees in Q 4(a & b) write the adjacency matrix representation of the trees and feed that adjacency matrix into your code. The code should print the node numbers in the order of the corresponding traversals. Please make sure code fully works.
Input Adjanceny Matrix (pictured): please hardcode adjacency matrices into code
For the tree a):
ABCDEFGHIJK
A01100000000
B 10110000000
C11001100000
D 01000010000
E00100001000
F00100000000
G00010000100
HOOO01000011
100000010000
J 00000001000
K00000001000
For the tree b)
4201100000000
1210111000000
6311000111000
801000000100
1601000000011
6000100001000
5700100000001
6500100100000
200010000010
1900001000100
2200001010000
Output:
For tree a), the traversals are as follows:
Pre-order (Root, Left, Right): A, B, D, G, C, E, H, J, K, I, F
In-order (Left, Root, Right): G, D, B, A, J, H, K, E, I, C, F
Post-order (Left, Right, Root): G, D, B, J,K,H, I, E, F, C, A
For tree b), the traversals are as follows:
Pre-order (Root, Left, Right): 42,12,8,2,16,22,19,65,53,60,57
In-order (Left, Root, Right): 2,8,12,19,22,65,16,42,57,60,53
Post-order (Left, Right, Root): 2,8,19,65,22,16,12,57,60,53,42
Problem statement: C + + Language In this

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 Programming Questions!