How treemap handles case of putting key on same index?

I tried out following code: public static void main (String[] args) throws java.lang.Exception { // sorting based on number of dots Map map =new TreeMap((o1, o2) -&…

Binary Search Tree’s add method in Java

I have a piece of code for inserting a node to Binary Search Tree in Java like: public class BST { private Node head; public BST() { this.head = null; } public void add(int data, Node head) { …