Question: Lab 7 : Trees Lab on Trees In class you learned that the binary tree data - structure could be represented in computer memory contiguously
Lab : Trees
Lab on Trees
In class you learned that the binary tree datastructure could be represented in computer memory contiguously or by random access.
Using whichever representation you are comfortable with, implement a tree. The tree will be inputted into the computer layerbylayer starting at the root. The data type of each node will be a String. Input is terminated with
For example:
blue
green
yellow
pink
red
purple
orange
black
brown
Which yield the following tree structure:
Tree structure
Question Output a preorder traversal of the input tree. Output should all be on one line separated by spaces.
eg output: blue green pink black brown red yellow purple orange
Question Output a Inorder traversal of the input tree.
eg output: black pink brown green red blue purple yellow orange
Question Output a postorder traversal of the input tree.
eg output: black brown pink red green purple orange yellow blue
Hint: The pseudocode for these procedures are given in the slides, you are welcome to use them. Remember only the order of instructions needs to change to answer all three questions above.
DO QUESTION QUESTIONN AND QUESTION
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
