Write an efficient algorithm to construct a full binary tree from a sequence of keys representing preorder traversal, and a boolean array which determines if the corresponding key in the preorder traversal is a leaf node or an internal node.
A full binary tree is a tree in which every node has either 0 or 2 children. Write an efficient algorithm to construct a full binary tree from given preorder and postorder sequence.
In this post, we will see the difference between Depth first search (DFS) and Breadth first search (BFS) algorithm which are used to traverse/search tree or graph data structure.
Write an efficient algorithm to construct a Cartesian tree from in-order traversal. A Cartesian tree is a binary tree with the heap property: the parent of any node has smaller value than the node itself.
Given a binary tree where each node has one extra pointer next, set next pointer to inorder successor for all nodes in the binary tree.
Given a binary tree, efficiently print all nodes between two given levels in a binary tree. The nodes for any level should be printed from left to right.
Given a binary tree, calculate the difference between sum of all nodes present at odd levels and sum of all nodes present at even level.
Given a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes 45 degree angle with the parent.
Given a binary tree, write an efficient algorithm to link nodes at the same level in the form of a linked list like structure.
In this post, we will implement Treap Data Structure and perform basic operations like insert, search and delete on it.
Write an efficient algorithm to find preorder traversal of a binary tree from its inorder and postorder sequence without constructing the tree.
Given a binary tree that is only one swap away from becoming a BST, convert the binary tree into BST in single traversal of it.