Binary Search Tree(BST) is a hierarchical data structure which is tree with a single reference to root node where each node has at most two child nodes (a left and a right child)
Nodes are organized by the Binary Search property:
• Every node is ordered by some key data field(s)
• For every node in the tree, its key is greater than its left child’s key and less than its right child’s key
Following implementation of BST
Input:
BinaryTree<String> tree = new BinaryTree<String>();
tree.add("Python");
tree.add("Java");
tree.add("Node.js");
tree.add("Angular.js");
Output:
[Angular.js, Java, Node.js, Python]
No comments:
Post a Comment