Binary tree implementation in java
This post will teach you how to implement a binary tree in java and perform the following functions on it. insert - Inserts the elements to binary tree printInOrder - To print the inorder elements of the binary tree maxDepth and minDepth - To find whether a tree is balanced or not commonAncestor - To find the common ancestor between two nodes findSum - to find all paths whose sum is equal to the given sum addToTree - To insert elements to the tree in such a way that there will be minimum number of leaves. findLevelLinkedList - To find elements in each level The java program is as follows: package com.algorithm; import java.util.ArrayList; import java.util.LinkedList; public class binaryTree { public static void main(String args[]) { new binaryTree().run(); } public static class Node { Node left; Node right; int value; public Node( int value) { this.value = value; } } public void run() { Node ro...