Binary tree implementation


I only see the implementation for binary search tree and not binary tree per se. Why is that ? Also in general, doing a google search returns only implementations for BST and not a B-tree. Are there good examples of binary tree insertions that are done dynamically ?

Course: Data Structures for Coding Interviews in Java - Learn Interactively
Lesson: What Makes a Tree Balanced? - Data Structures for Coding Interviews in Java

Hi @Ajay,

The difference between a binary search tree and a regular binary tree is that,
In Binary search tree.

  • A nodes left subtree has values lesser than the nodes right key, and vice versa for the right subtree
  • The Right and Left subtree must also be Binary trees.

Given this, insertion in a Binary tree is simple, the new node is inserted in the first available position in the binary tree. So unlike binary search trees, there are no special algorithms for the insertion of a new node.

Let us know if you have any more queries.