Please answer this programming question as fast as possible. Will upvote


![es/34463/quizzes/213587/take public int DFSearch (int value) //your code here .. public BSTree makeBST (int] postorder) //you](http://img.homeworklib.com/questions/04f8eef0-5c5a-11eb-bc37-7330d840fddb.png?x-oss-process=image/resize,w_560)

a)
CODE
public int maxElement() {
if(root == null) {
System.out.println("Tree is empty");
return -1;
}
//we found the max value
if(root.right == null) {
return root.data;
}
return maxElement(root.right);
}
}
b)
CODE
public void preOrderPrint()
{
if (node == null)
return;
/* first print data of node */
System.out.print(node.key + " ");
/* then recur on left sutree */
preOrderPrint(node.left);
/* now recur on right subtree */
preOrderPrint(node.right);
}
NOTE: As per HOMEWORKLIB POLICY, I am allowed to answer only 2 coding questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.
Please answer this programming question as fast as possible. Will upvote 45 pts Question 2 Let...
Question B1 You are given the following Java classes: public class Queue { private static class Node { Object object; Node next; Node () { object = null; next = null; } Node (Object object, Node next) { this.object = object; this.next = next; private Node header; private int size = 0; // size shows the no of elements in queue public Object dequeue () { if (size == 0 ) { return null; else { Object remove_object = header.object;...
1) Extend the Binary Search Tree ADT to include
a public method leafCount that returns the number of leaf nodes in
the tree.
2) Extend the Binary Search Tree ADT to include a
public method singleParent-Count that returns the number of nodes
in the tree that have only one child.
3) The Binary search tree ADT is extended to
include a boolean method similarTrees that receives references to
two binary trees and determines whether the shapes of the trees are...
In this assignment, you will add several methods to the Binary Search Tree. You should have completed the following three methods in the lab: public void insert(Key key, Value value) public Value get(Key key) public void inorder(Node root) For this assignment, you will implement the following: public void remove(Node root, Key key) public Key getMin(Node n) public Key getMax(Node n) public int height(Node n) The main method contains the statements to check whether your implementation works. You need to change...
C++ Binary tree, help pls #pragma once // include this library to use NULL, otherwise use nullptr instead #include <cstddef> #include <iostream> #include "node.hpp" template<class T> class BST{ public: // Constructor for the BST class, creates an empty tree BST(void); // Destructor for the BST class, destroys the tree ~BST(void); // Inserts data into the tree // param: The data to be inserted into the tree void insert(T); // Removes data from the tree // param: The data to be...
Please I need help ASAP Java Programing: Binary Search Tree Fully implement the BST class in Listing 25.4 (on page 961 of the 11th Edition of the text). Design and write a (main) driver program to completely test every method in the BST class to ensure the class meets all its requirements. You should read the Listing 25.5: TestBST.java for an idea of what your program should look like. Listing 25.4 BST.java public class BST> extends AbstractTree { protected TreeNode...
Write a client method that returns a count of the number of
nodes in a binary search tree that contain scores less than or
equal to a passed-in argument (parameter) value. The method header
is:
int countLowerScores (BinarySearchTree tree, int maxValue)
The BinarySearchTree contains these methods in the
picture.
public class BinarySearchTreecT> implements BSTInterfacecT> //reference to the root of this BST public BSTNode<T> root; public Comparator<T> comp: IIused for all comparisons public boolean found: / used by remove public BinarYSearchTree()...
Hello, I've been working on this for a while and I can't figure the rest out. Need asap if anyone can help. maxBSt,minBST,isBST, and inOrder package lab7; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; public class TreeExercise { /* * Construct BST from preorder traversal */ public static Node<Integer> consBSTfromPreOrder(int[] arr, int start, int end) { if(start > end) return null; Node<Integer> root = new Node<Integer>(arr[start],...
Please help me with me. I did the first part to write the operations but in the driver its shows me errors, can't fix it. Help me. Need help with this to run the application. /** * BinaryTreeNode represents a node in a binary tree with a left and * right child. * * @author Java Foundations * @version 4.0 */ public class BinaryTreeNode { protected T element; protected BinaryTreeNode left, right; /** * Creates a new tree node with...
In Java. How would this method look?
LinkedBinaryTree.java
import java.util.Iterator;
public class LinkedBinaryTree implements BinaryTreeADT {
private BinaryTreeNode root;
/**
* Creates an empty binary tree.
*/
public LinkedBinaryTree() {
root = null;
}
/**
* Creates a binary tree from an existing root.
*/
public LinkedBinaryTree(BinaryTreeNode root) {
this.root = root;
}
/**
* Creates a binary tree with the specified element...
using java to write,show me the output. please write some
common.
You CAN NOT use inbuild functions for Tree ADT operations.
using code below to finsih
public class Main
{
public static void main(String[] args) {
BinaryTree tree = new
BinaryTree();
tree.root = new Node(1);
tree.root.left = new Node(2);
tree.root.right = new Node(3);
tree.root.left.left = new Node(4);
tree.root.left.right = new Node(5);
tree.root.right.left = new Node(6);
tree.root.right.right = new Node(7);
tree.root.left.left.left = new Node(8);
tree.root.left.left .right= new Node(9);...