There are two binary tree and you have to find that , one of the binary tree is the sub-tree in another binary tree. We have three cases here. The root of subtree matches with the root of binary tree. If above condition fails, We look into left-subtree of the main binary tree to find […]
Java code to find diameter of a binary tree
Diameter of a binary tree is the maximum width at any node level. The maximum width can be at last level and that can be the diameter of a binary tree. You can watch me code this solution on youtube. We need three values to find the diameter of a binary tree. diameter of left-subtree […]
AVL Tree Insertion Deletion Search in C Programming Language
AVL Tree is a Balanced Binary Search Tree. What does balance means? It means that, we try to minimize the number of traversals, during search, insertion or deletion or any other operations on a binary search tree. We achieve this by trying to minimize the height differences between the left sub-tree and right-sub tree. The […]
Do inorder traversal on a binary tree in java.
Hello there. In this article, we will be traversing a binary tree, and we also print the data stored in those node. In the inorder traversal, we print the left child – root – right child. Here is simple recursive algorithm to do that. go to left child – print the left child print the root […]
Create a complete binary tree from an array of data in java
Note :- Using java 8 and above. Hi there… Today, I am going to write a java program which will take an var-arg of character, you can use any data-type you want. Data type is not the focus here. The main focus is the process of creating a binary tree. I am using functional programming to do […]
Class to represent a binary tree node in java.
A node in a binary tree contains data and reference to it’s left and right child. You can add as many instance variables you want, because all of them represent data. You can have multiple maps, multiple lists another class objects. Because, all of those are data. But, objects to access the left and right […]