Lowest Common Ancestor of a Binary Tree Part II
July 21, 2011 in binary tree
Given a binary tree, find the lowest common ancestor of two given nodes in the tree. Each node contains a parent pointer which links to its parent.
July 21, 2011 in binary tree
Given a binary tree, find the lowest common ancestor of two given nodes in the tree. Each node contains a parent pointer which links to its parent.
July 18, 2011 in binary tree
Given a binary tree, find the lowest common ancestor of two given nodes in the tree.
July 17, 2011 in binary tree
Given a binary search tree (BST), find the lowest common ancestor of two given nodes in the BST.
April 20, 2011 in binary tree
Given preorder and inorder traversal of a tree, construct the binary tree.
November 29, 2010 in binary tree, linked list
Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers in a doubly-linked list.
November 27, 2010 in binary tree, linked list
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
November 25, 2010 in binary tree, divide and conquer
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
November 22, 2010 in binary tree
Given a binary tree, find the largest Binary Search Tree (BST), where largest means BST with largest number of nodes in it. The largest BST may or may not include all of its descendants.
November 18, 2010 in binary tree
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.
October 27, 2010 in binary tree
Given a binary tree, print the elements in post-order iteratively without using recursion.
October 20, 2010 in binary tree
Print all edge nodes of a complete binary tree anti-clockwise.
That is all the left most nodes starting at root, then the leaves left to right and finally all the rightmost nodes.
In other words, print the boundary of the tree.Variant: Print the same for a tree that is not complete.
September 29, 2010 in binary tree
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called ‘serialization’ and reading back from the file to reconstruct the exact same binary tree is ‘deserialization’.
September 28, 2010 in binary tree
Describe an algorithm to save a Binary Search Tree (BST) to a file in terms of run-time and disk space complexity. You must be able to restore to the exact original BST using the saved format.
September 18, 2010 in binary tree
Have you ever thought of pretty-printing a binary tree?
Read the rest of this entry →
September 18, 2010 in binary tree
Given a binary tree, print out the tree in zig zag level order (ie, from left to right, then right to left for the next level and alternate between). Output a newline after the end of each level. Read the rest of this entry →
September 17, 2010 in binary tree
Given a binary tree, print out the tree in level order (ie, from left to right, level by level). Output a newline after the end of each level. Breadth First Search (BFS) is not allowed. Read the rest of this entry →
September 16, 2010 in binary tree
Given a binary tree, print out the tree in level order (ie, from left to right, level by level). Output a newline after the end of each level. Read the rest of this entry →
September 14, 2010 in binary tree
Write a function isBST(BinaryTree *node) to verify if a given binary tree is a Binary Search Tree (BST) or not.
April 21, 2010 in binary tree
Given a binary tree, find its maximum height.
March 12, 2010 in binary tree
Given a binary tree
12345 struct Node {Node* leftChild;Node* rightChild;Node* nextRight;}Populate the nextRight pointers in each node.