Question: Write a C + + program that works with Linked Lists and performs the following operations: traversal Description: Will display each of the data stored
Write a C program that works with Linked Lists and performs the following operations:
traversal
Description: Will display each of the data stored in the BST depending on the input parameter:
Preorder
Inorder
Postorder
Level by level
Input: An integer
Output: Nothing
Precondition: A valid BST
Postcondition: Nothing
height
Description: Will return the height of the BST
Input: Nothing
Output: An integer that will indicate the height of the BST
Precondition: A valid BST
Postcondition: Nothing
ancestors
Description: Will display the ancestors of a data
Input: The data whose ancestors you want to know
Output: Nothing
Precondition: A valid BST
Postcondition: Nothing
whatlevelamI
Description: Will return an integer that indicates the level at which a data is found, or if it is not found in the BST
Input: A data to find its height
Output: Integer indicating the level of the data in the BST or if it is not found
Precondition A valid BST
Postcondition Nothing
input:
n number of nodes to insert
n integer values
m number of nodes to remove
m integer values
q number of values to display their ancestors
q integer values
r number of values to display the level they are at
r integer values
output:
preorder traversal, values separated by exactly one space, the last value also has a space
inorder traversal, values separated by exactly one space, the last value also has a space
postorder traversal, values separated by exactly one space, the last value also has a space
levelbylevel traversal, values separated by exactly one space, the last value also has a space
value of the total height of the tree without spaces at the end of the tree final
list of ancestors of the q values, separated by exactly one space, the last value also has a space
list of integers representing the level of each of the r values read one on each line, no trailing spaces
input example
output example
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
