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.
Given a doubly linked list, sort it using merge sort algorithm.
Given a distinct sequence of keys, check if it can represent a preorder traversal of a binary search tree (BST).
Write an efficient algorithm to convert a ternary tree into a doubly linked list. A ternary tree is a tree data structure in which each node has at most three child nodes distinguished as left, mid and right.
Given a stair case, find total number of ways to reach the n’th stair from bottom of the stair when a person is only allowed to take at-most m steps at a time.
In this post, we will see how to reverse a doubly linked list using iteration and recursion.
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.
Given a n x 4 matrix where n is a positive number, find number of ways to fill the matrix with 1 x 4 tiles.
Given a linked list, pairwise swap its adjacent nodes. The swapping of data is not allowed, only links should be changed.
Given a BST, count subtrees in it whose nodes lies within a given range. For example, consider below BST. The number of subtrees with nodes in the range [5, 20] are 6.
Given a linked list which can grow in both horizontal and vertical directions (right and down), flatten it into a sorted singly linked list provided that each horizontal and vertical list is already sorted.
Given a stair case, find total number of ways to reach the n’th stair from bottom of the stair when a person is only allowed to climb either 1 or 2 or 3 stairs at a time.