## Iterative program to find distance of a node from root

Given the root of a binary tree and a key x in it, find the distance of the given key from the root node. Distance… Read More »

- Queue in Standard Template Library (STL)
- Convert a Binary Tree into its Mirror Tree
- Sum of leaf nodes at minimum level
- Print level order traversal line by line | Set 1
- Shortest path in an unweighted graph
- ZigZag Tree Traversal
- BFS using STL for competitive coding
- Sum of cousins of a given node in a Binary Tree
- queue::push() and queue::pop() in C++ STL
- Construct BST from its given level order traversal
- Level order traversal with direction change after every two levels
- Check if the given array can represent Level Order Traversal of Binary Search Tree
- Path in a Rectangle with Circles
- Reverse a path in BST using queue
- Iterative diagonal traversal of binary tree
- Reversing a queue using recursion
- Sorting a Queue without extra space
- K-th ancestor of a node in Binary Tree
- priority_queue::push() and priority_queue::pop() in C++ STL
- General Tree (Each node can have arbitrary number of children) Level Order Traversal
- queue::front() and queue::back() in C++ STL
- Check whether a binary tree is a full binary tree or not | Iterative Approach
- Check if two nodes are cousins in a Binary Tree | Set-2
- priority_queue::empty() and priority_queue::size() in C++ STL
- Number of siblings of a given Node in n-ary Tree
- Smallest multiple of a given number made of digits 0 and 9 only
- queue::swap() in C++ STL
- priority_queue::top() in C++ STL
- Level order traversal in spiral form | Using one stack and one queue
- queue::emplace() in C++ STL

Given the root of a binary tree and a key x in it, find the distance of the given key from the root node. Distance… Read More »

Given a Queue of integers. The task is to check if consecutive elements in the queue are pairwise consecutive. Examples: Input: 1 2 5 6… 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 »

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 an array of integers and a number K with initial and final values. Your task is to find the minimum number of steps required… Read More »

Given lengths of n rods in an array a[]. If any person picks any rod, half of the longest rod (or (max + 1) /… 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. You… Read More »

Given a root node to a tree, find the sum of all the leaf nodes which are at maximum depth from root node. Example: 1… Read More »

Given start, end and an array of N numbers. At each step, start is multiplied with any number in the array and then mod operation… Read More »

Given N numbers which have a permutation of first N numbers. In a single operation, any prefix can be reversed. The task is to find… 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 two binary trees, the task is to check whether the two binary trees is a mirror of each other or not. Mirror of a… Read More »

Given a Binary Tree having positive and negative nodes, the task is to find maximum product level in it. Examples: Input : 4 / \… Read More »

Given a queue of integers of even length, rearrange the elements by interleaving the first half of the queue with the second half of the… Read More »

Given a binary tree. Find if a given vertical level of the binary tree is sorted or not. (For the case when two nodes are… Read More »