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 […]
Stack datastructure implementation in C programming Language.
Stack is an abstract data-structure. This data-structure allows user to access the contents in Last In First Out order. This means, the latest element which was put in the data-structure, will be the first one to be removed on remove operation. You can watch my video, where I code this implementation. The operation, where we […]
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 […]
Implement Queue Data Structure using C programming language
You can watch me live-code this data-structure on YouTube for better understanding.You can read the text and follow the video with it for clear understanding. A queue is an abstract Data-Structure where, a data item is inserted or added at one end. And, data item is removed from other end. To keep track of two […]
Stack Implementation using C language
You can watch me live code the Stack Datastructure on youtube. You can get the entire source code from github I have put all the function declaration in a header file. struct Stack{ int top; int capacity; int *data; }; //Creation struct Stack *createStack(int *capacity); //Deletion int deleteStack(struct Stack *stack); //Status Checks int isStackFull(struct Stack *stack); […]
Convert infix equation to postfix in java
We know stack is first in and last out. The first to go inside a stack is going to be the last to come out of it. So, the aloglrithm to convert a infix to postfix is simple. We print all the operands. Operands are something which are not mathematical symbols and does not represent […]
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 […]