This repository contains the implementation for a Binary Search Tree (BST) that holds integers as its data points. The two classes used to implement this are Node.java
& BinarySearchTree.java
.
The BinarySearchTree.java
class contains the following unique methods:
Node getRoot()
- returns the root of the BSTint getNodeCount()
- returns the number of nodes in the BSTvoid insert(Node root, int key)
- inserts a node in the BSTvoid preorderRec(Node root)
- recursive method that prints the preorder traversal of the BSTNode kthBiggest(Node root, int k)
- returns the kth biggest element in the BSTint sum(Node root)
- returns the sum of all the keys in the BST