Print All The Nodes Which are X distance from the Given Node

Objective: Given Binary Tree, Print All The Nodes Which are X distance from the Given Node.

Example :

Approach:

Quite Tricky solution, i will explain using the example given in the picture.

Read morePrint All The Nodes Which are X distance from the Given Node

In a Binary Tree, Create Linked Lists of all the nodes at each depth.

Objective: Given a Binary tree create Linked Lists of all the nodes at each depth , say if the tree has height k then create k linked lists.

NOTE : This problem is very similar “Print binary tree, each level in one line

Input: A binary tree

Output: K linked lists if the height of tree is k. Each linked list will have all the nodes of each level.

Example:

Read moreIn a Binary Tree, Create Linked Lists of all the nodes at each depth.

Level Order Traversal, Print each level in separate line.

Objective: Given a Binary tree , Print each level of a tree in separate line.

NOTE : This problem is very similar ” Create Linked Lists of all the nodes at each depth “

Input: A binary tree

Output: Each level of binary tree, in one line

Example:

Read moreLevel Order Traversal, Print each level in separate line.