Invert alternate levels of a perfect binary tree
Write an efficient algorithm to invert alternate levels of a perfect binary tree.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedWrite an efficient algorithm to invert alternate levels of a perfect binary tree.
Write an efficient algorithm to construct a binary tree from given inorder and level-order sequence.
Write an efficient algorithm to construct a binary tree from the given inorder and postorder traversals.
Given a binary search tree (BST), efficiently convert it into a min-heap. In order words, convert a binary search tree into a complete binary tree where each node has a higher value than its parent’s value.
Given a binary tree, convert it into a doubly-linked list following the spiral order.
This post will explore a threaded binary tree and convert a normal binary tree into a threaded binary tree.
Write an efficient code to clone a binary tree with each node containing an additional random pointer. The random pointer can point to any random node of the binary tree or can be null.
Given a binary tree, check if it is a min-heap or not. In order words, the binary tree must be a complete binary tree where each node has a higher value than its parent’s value.
Write an efficient algorithm to construct a binary tree from the given inorder and preorder sequence.
Given a binary search tree, find a triplet with a given sum present in it.
Given two binary search trees, merge them into a doubly-linked list in sorted order.
Given a binary search tree (BST), convert it into a height-balanced binary search tree. For a height-balanced binary search tree, the difference between the height of the left and right subtree of every node is never more than 1.