The third programming project involves writing a program that allows the user to enter a binary tree in a parenthesized prefix format and then allows it to be categorized and allows various features of that tree to be displayed.

computer science

Description

The third programming project involves writing a program that allows the user to enter a binary tree in a parenthesized prefix format and then allows it to be categorized and allows various features of that tree to be displayed. An example of a tree written in the input format is the following:


In the above example, data in each node of the tree contains a single alphanumeric character. No spaces are permitted. Each tree is enclosed in parentheses. Inside those parentheses, after the single character are either zero, one or two subtrees also enclosed in parentheses. When only one subtree is present, it is the left subtree and when two are present, they represent the left and right subtrees. So the above string represents the following binary tree:


The various categorizations include the following: 

1. Whether the binary tree is balanced, which means for each node in the tree, the absolute difference between the height of its left and right subtrees is at most 

1. The above binary tree is balanced. 

2. Whether the binary tree is full. A full binary tree has the maximum number of nodes for a tree of its height. The above tree is not full because a tree of that height can contain 7 nodes, but the above tree only has 6. 

3. Whether the binary tree is proper. In a proper binary tree, every node has either 0 or 2 children. The above tree is not proper because the node containing z has only one child. 


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.