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

Given a Binary Search Tree that is populated with numerical data, write an algor

ID: 3833405 • Letter: G

Question

Given a Binary Search Tree that is populated with numerical data, write an algorithm that will determine the largest value in the tree that is less than the median of all the values in the tree.

Express your algorithm in Java-like pseudocode. You may use any of the operations supported by DJW's Binary Search Tree implementation (see BSTInterface.java).

Your solution must be developed at the application level.

Make sure you know what the median is.

If you use the operations in DJW's BSTInterface.java, please use numBST for the name of the BinarySearchTree object. Object instantiation and variable declarations are not needed. Do not include any logic in your solution that populates or changes the values in the tree.

Note: partial credit may be awarded for submissions that describe how to determine the median.

Explanation / Answer

/* * Java Program to Implement Binary Search Tree */ import java.util.Scanner; /* Class BSTNode */ class BSTNode { BSTNode left, right; int data; /* Constructor */ public BSTNode() { left = null; right = null; data = 0; } /* Constructor */ public BSTNode(int n) { left = null; right = null; data = n; } /* Function to set left node */ public void setLeft(BSTNode n) { left = n; } /* Function to set right node */ public void setRight(BSTNode n) { right = n; } /* Function to get left node */ public BSTNode getLeft() { return left; } /* Function to get right node */ public BSTNode getRight() { return right; } /* Function to set data to node */ public void setData(int d) { data = d; } /* Function to get data from node */ public int getData() { return data; } } /* Class BST */ class BST { private BSTNode root; /* Constructor */ public BST() { root = null; } /* Function to check if tree is empty */ public boolean isEmpty() { return root == null; } /* Functions to insert data */ public void insert(int data) { root = insert(root, data); } /* Function to insert data recursively */ private BSTNode insert(BSTNode node, int data) { if (node == null) node = new BSTNode(data); else { if (data
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