Skip to content

Tag Archives: tree-level-order

Given a binary tree and an integer b representing budget. The task is to find the count of maximum number of leaf nodes that can… Read More
Given a binary tree and a node in the binary tree, find Levelorder successor of the given node. That is, the node that appears after… Read More
Given a binary tree and a node in the binary tree, find Levelorder Predecessor of the given node. That is, the node that appears before… Read More
Given a tree, with N nodes and E edges (every edge is denoted by two integers, X, Y stating that X is the parent of… Read More
Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. Given a binary tree, print… Read More
Given the root of a binary tree and a key x in it, find the distance of the given key from the root node. Dis­tance… Read More
Given an array of elements, the task is to insert these elements in level order and construct a tree. Input : arr[] = {10, 20,… Read More
Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7.    … Read More
Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. Given a binary tree, print… Read More
Given a binary tree and data value of a node. The task is to find the sum of cousin nodes of given node. If given… Read More
Given a binary tree and a node, print all cousins of given node. Note that siblings should not be printed.Examples:   Input : root of below… Read More
Given a root node to a tree, find the sum of all the leaf nodes which are at maximum depth from the root node.Example:  1… Read More
Given a binary tree, flatten it into linked list in-place. Usage of auxiliary data structure is not allowed. After flattening, left of each node should… Read More
Given a binary tree and the two nodes say ‘a’ and ‘b’, determine whether two given nodes are cousins of each other or not. Two… Read More
Given a binary tree. The task is to check if the binary tree is sorted level-wise or not. A binary tree is level sorted if… Read More