Skip to content
Mission Peace edited this page Oct 9, 2016 · 11 revisions
  1. Self balancing tree AVL tree - AVLTree.java
  2. Given an arbitrary binary tree, convert it to a binary tree that holds Children Sum Property. You can only increment data values in any node - ArbitaryTreeToChildSumTree.java
  3. Given Preorder traversal of a BST, check if each non-leaf node has only one child. Assume that the BST contains unique entries - BSTOneChildPreOrderTraversal.java
  4. Btree implementation - BTree.java
  5. Binary tree operations - BinaryTree.java
  6. Convert a binary tree to circular link list - BinaryTreeToCircularLinkList.java
  7. Write a function to connect all the adjacent nodes at the same level in a binary tree - ConnectNodesAtSameLevel.java
  8. Given two arrays that represent preorder and postorder traversals of a full binary tree, construct the binary tree - ConstructFullTreeFromPreOrderPostOrder.java
  9. Construct tree from preorder and inorder traversal - ConstructTreeFromInOrderPreOrder.java
  10. Given inorder and level-order traversals of a Binary Tree, construct the Binary Tree - ConstructTreeFromLevelOrderInOrder.java
  11. Write a function to count number of smaller elements on right of each element in an array - CountNumberOfSmallerElementOnRight.java
  12. Given binary tree and two nodes, tell if these two nodes are cousins of each other or not - CousinNodes.java
  13. Diameter of binary tree - DiameterOfTree.java
  14. Huffman encoding - HuffmanEncoding.java
  15. Given two arrays which represent a sequence of keys. Imagine we make a Binary Search Tree (BST) from each array. We need to tell whether two BSTs will be identical or not without actually constructing the tree - IdenticalTrees.java
  16. Given a binary tree, find largest BST in this binary tree - LargestBSTInBinaryTree.java
  17. Given a Binary Tree, find size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there is no edge between any two nodes of the subset - LargestIndependentSetInTree.java
  18. Level order traversal of binary tree - LevelOrderTraversal.java
  19. Create an iterator to traverse a binary tree. When the next function is called on the binary tree return the value at the next node as if you are doing an inorder traversal of the tree - NextInorderSuccessorIterator.java
  20. Given a binary tree and a number k, print nodes at distance k from given node - NodesAtDistanceK.java
  21. Populate inorder successor for all nodes - PopulateInOrderSuccessor.java
  22. Inorder successor of two tree -NextInorderSucessorOfTwoTree.java
  23. Given preorder traversal of a binary search tree, construct the BST - ConstructBSTFromPreOrderArray.java
  24. Print two BST in sorted form - PrintTwoBSTInSortedForm.java
  25. Given a binary tree and a number, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals the given number - RootToLeafToSum.java
  26. Range query segment tree - SegmentTree.java segmenttreesum.py
  27. Segment tree for minimum range query - SegmentTreeMinimumRangeQuery.java
  28. Given a binary tree with positive and negative numbers, sink negative numbers to the bottom of the tree - SinkNegativeToBottom.java
  29. Given an array that stores a complete Binary Search Tree, write a function that efficiently prints the given array in ascending order - SortedOrderPrintCompleteTreeArray.java
  30. Write a function that returns true if the given Binary Tree is SumTree else false. A SumTree is a Binary Tree where the value of a node is equal to sum of the nodes present in its left subtree and right subtree - SumTree.java
  31. Inorder,preorder,postorder traversals - TreeTraversals.java
  32. Given a binary tree, print it vertically - VerticalTreePrinting.java
  33. Given a Binary Search Tree (BST), modify it so that all greater values in the given BST are added to every node - AddGreaterValueNodeToEveryNode.java
  34. Print all nodes with no sibling - NodesWithNoSibling.java
  35. Boundary traversal of binary tree - BoundaryTraversal.java
  36. Convert a binary tree into double link list - BinaryTreeToDoubleLinkList.java
  37. Given a binary tree, tell if it is a complete tree or not. IsCompleteBinaryTree.java
  38. Given a preorder traversal of a tree with 0 or 2 children and char array where L stands for leaf node and N stands for inner node, create binary tree from it - ConstructTreeFromPreOrderTraversalWith0or2Child.java
  39. Convert a binary tree(not BST) to a sorted link list - BinaryTreeToSortedLinkList.java
  40. Given an inorder traversal of tree where each node is greater than its child nodes, create binary tree - ContructTreeFromInOrderTraversalRootGreaterThanChild.java
  41. Given two nodes value find lowest common ancestor of these two nodes - LowestCommonAncestorInBinaryTree.java
  42. Write a function to detect if two trees are isomorphic. Two trees are called isomorphic if one of them can be obtained from other by a series of flips - TreeIsomorphism.java
  43. Vertex cover for binary tree using DP - VertexCoverBinaryTreeDP.java
  44. Convert a binary tree(Not BST) to sorted linklist. DegenerateBinaryTreeToSortedLL
  45. Search in binary search tree - BSTSearch.java
  46. Given a binary tree, return true if is binary search tree else return false -IsBST.java
  47. Given two tree return true if they represent same tree else return false. SameTree.java
  48. Tree traversal in level and spiral order - TreeTraversalInSpiralOrder.java
  49. Tree traversal printing each level on new line - TreeTraversalLevelByLevel.java
  50. Level order traversal in reverse - LevelOrderTraversalInReverse.java
  51. Fenwick tree - FenwickTree.java
  52. Red black tree - RedBlackTree.java
  53. Given an preorder sequence determine if it is of binary search tree or not IsPreOrderArrayBST.java
  54. Succinct encoding/decoding of binary tree SuccinctTree.java
  55. Create binary tree from parent representation - BinaryTreeFromParentRepresentation.java
  56. Given pre/inorder traversal of binary tree, create post order traversal - PrintPostOrderFromPreOrderInOrder.java
  57. Construct all binary search tree from inorder traversal ConstructAllBinaryTreeFromInorderTraversal.java
  58. Interval tree IntervalTree.java
  59. Morris inorder/preorder traversal of tree - MorrisTraversal.java
  60. Serialize deserialize binary tree - SerializeDeserializeBinaryTree.java
  61. Lowest common ancestor in binary search tree - LowestCommonAncestoryBinarySearchTree.java
  62. Inorder successor of binary tree - InorderSuccessor.java
  63. Maximum sum path in binary tree - BinaryTreeMaximumPathSum.java
  64. Count number of nodes in complete tree - CountNodesCompleteTree.java
  65. Check if binary tree is height balanced - HeightBalanced.java
  66. Given an array where elements are sorted in ascending order, convert it to a height balanced BST - SortedArrayToBST.java
  67. Given a binary tree, flatten it to a linked list in-place in preorder traversal - FlattenLinkListToBinaryTreePreorder.java
  68. Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum - PathSum.java
  69. Given a binary tree, count the number of uni-value subtrees - CountUnivalueTree.java
  70. Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target - KClosestValueInBinaryTree.java.java
  71. Strip leaves of the tree and collect them in list - LeavesOfBinaryTree.java
Clone this wiki locally