Print nodes of a binary tree in vertical order
Given a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes a 45–degree angle with the parent.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary tree, print its nodes in vertical order. Assume that the left and right child of a node makes a 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.
This post will implement a treap data structure, a combination of a binary search tree and a heap, and perform basic operations like insert, search, and delete on it.
This post will implement a queue using the stack data structure. In other words, design a queue that supports enqueue and dequeue operations using standard push and pop operations of the stack.
Write an efficient algorithm to find a binary tree’s preorder traversal from its inorder and postorder sequence without constructing the tree.
Find all n–digit numbers with an equal sum of digits at even and odd index, where n varies from 1 to 9.
Calculate the total number of ways to achieve a given sum with n throws of dice having k faces.
Given a binary tree, count all subtrees in it such that every node in the subtree has the same value.
Given a BST, find the inorder successor of a given key in it. If the given key does not lie in the BST, then return the next greater key (if any) present in the BST.
Given a binary tree, write an efficient algorithm to find the maximum sum path between any two leaves in it.
Given a binary tree, write an efficient algorithm to find all nodes present at a given distance from any leaf node. We need to find only those nodes that are present in the root-to-leaf path for that leaf.
Given a binary tree that is only one swap away from becoming a BST, convert it into a BST in a single traversal.