Question
Write a PROCEDURAL program that creates a tree for the following string data (stored in an input file sample shown below), where: 1)the leftmost string
Write a PROCEDURAL program that creates a tree for the following string data (stored in an input file sample shown below), where:
1)the leftmost string goes into a node;
2)the middle string goes into the nodes left child; and,
3)the rightmost string goes into the nodes right child.
However, the string null in the middle position means the node has no left child, and the string null in the rightmost position means the node has no right child.
The first line contains the root nodes string in the leftmost position, and for every non-null string, there must be a line with that string in the leftmost position. Use the following data in the input file:
dog over brown
over red jumped
red The quick
The null null
quick null null
jumped fox null
fox null null
brown the lazy
the null null
lazy null null
This data produces the following tree:
Note that the string The is not the same as the string the.
It is recommended that you load the tree using preorder searches while reading the input file. After the tree is loaded your program should print out the result of a postorder traversal with a space between each string and a newline at the end.
dog over brown red jumped the lazy The ulStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started