Question: Given the following class representing a node in a binary tree, answer the following questions: public class BinaryNode { public E element;//data public BinaryNode

 Given the following class representing a node in a binary tree, answer 

Given the following class representing a node in a binary tree, answer the following questions: public class BinaryNode { public E element;//data public BinaryNode left://left child public BinaryNode right://right child public BinaryNode(E element){ this(element, null, null); 1 public BinaryNode(E element, BinaryNode left. BinaryNode right) this left-left: this.right-right: this.element element; 1 a. (10 points) Write a few lines of Java code that constructs an object of BinaryNode (called root) which represents the root of a binary tree with the following features: tree's root has an element equal to 5, and has two children root's left child has an element equal to 3 and has two children with elements 2 and 6 (left child contains 2 and right child contains 6) . root's right child has an element equal to 7 and a single child on the right with element 10 . Tree has only 6 nodes b. (5 points) is the binary tree defined in previous part considered to be a Binary Search Tree? Briefly justify your answer. c. (5 points) What is the height of the tree defined in part a? Briefly justify your answer. d. (5 points) is the tree defined in previous part balanced? Briefly justify your answer. e. (9 points) Write down the pre-order, In-order and post-order traversal of the tree defined in part a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

java public class BinaryNode public E element data public BinaryNode left left child public BinaryNode right right child public BinaryNodeE element th... View full answer

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!