Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Step 1) Draw the binary search tree that results from adding the following integ

ID: 3535000 • Letter: S

Question

Step 1)

Draw the binary search tree that results from adding the following integers (34 45 3 87 65 32 1 12 17). Assume our simple implementation with no balancing mechanism.

I did that.

Then


Step 2)

Complete the two constructors and operations of removeMin, findMin, removeMax and findMax methods for the LinkedBinarySearchTree Class.


/**
* ExpressionTree represents an expression tree of operators and operands.
*
*
*/

package jss2;

public class ExpressionTree extends LinkedBinaryTree<ExpressionTreeObj>
{
/**
* Creates an empty expression tree.
*/
public ExpressionTree()
{
super();
}

/**
* Constructs a expression tree from the two specified expression
* trees.
*
* @param element the expression tree for the center
* @param leftSubtree the expression tree for the left subtree
* @param rightSubtree the expression tree for the right subtree
*/
public ExpressionTree (ExpressionTreeObj element,
ExpressionTree leftSubtree, ExpressionTree rightSubtree)
{

root = new BinaryTreeNode<T> (element);
count = 1;
if (leftSubtree != null)
{
count = count + leftSubtree.size();
root.left = leftSubtree.root;

}
else
root.left = null;

if (rightSubtree !=null)
{
count = count + rightSubtree.size();
root.right = rightSubtree.root;
}
else
root.right=null;

}



/**
* Evaluates the expression tree by calling the recursive
* evaluateNode method.
*
* @return the integer evaluation of the tree
*/
public int evaluateTree()
{
return evaluateNode(root);
}

/**
* Recursively evaluates each node of the tree.
*
* @param root the root of the tree to be evaluated
* @return the integer evaluation of the tree
*/
public int evaluateNode(BinaryTreeNode root)
{
int result;
int operand1;
int operand2;
ExpressionTreeObj temp;

if (root==null)
result = 0;
else
{
temp = (ExpressionTreeObj)root.element;

if (temp.isOperator(temp))
{
operand1 = evaluateNode(root.left);
operand2 = evaluateNode(root.right);
result = computeTerm(temp.getOperator(), operand1, operand2);
}
else
result = temp.getValue();
}

return result;

}


/**
* Evaluates a term consisting of an operator and two operands.
*
* @param operator the operator for the expression
* @param operand1 the first operand for the expression
* @param operand2 the second operand for the expression
*/
private static int computeTerm(char operator, int operand1, int operand2)
{
int result=0;

if (operator == '+')
result = operand1 + operand2;

else if (operator == '-')
result = operand1 - operand2;
else if (operator == '*')
result = operand1 * operand2;
else
result = operand1 / operand2;

return result;
}
}

I get the errors back


ÃExpressionTree.java:31: cannot find symbol
ÃÃ §Ãsymbol : class T
ÃÃ §Ãlocation: class jss2.ExpressionTree
ÃÃ §Ã root = new BinaryTreeNode<T> (element);
ÃÃ §Ã ^
à ¼ §ÃExpressionTree.java:92: isOperator() in jss2.ExpressionTreeObj cannot be applied to (jss2.ExpressionTreeObj)
ÃÃ §Ã if (temp.isOperator(temp))




Step 3)


Explanation / Answer

See this might help you..

every node has left and right nodes. Below is how a node should look like:

Below is a simple class that traverses, adds, and searches for a particular node value:


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote