Convert a binary tree into a doubly-linked list in spiral order
Given a binary tree, convert it into a doubly-linked list following the spiral order.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven 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.
Given an M × N matrix of integers whose each cell can contain a negative, zero, or a positive value, determine the minimum number of passes required to convert all negative values in the matrix positive.
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.
Given a linked list of characters, recursively check if it is palindrome or not.
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 an array of non-negative integers, where each array element represents the maximum number of positions one can move forward from that element. Find the minimum number of jumps required to reach a given destination from a given source within the array.
Given two binary search trees, merge them into a doubly-linked list in sorted order.
Given a directed acyclic graph (DAG) and a source vertex, find the cost of the longest path from the source vertex to all other vertices present in the graph. If the vertex can’t be reached from the given source vertex, print its distance as infinity.
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.