newszine

Find Bottom Left Tree Value | Tree Problem | LeetCode 513

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, write a program to find out the leftmost value in the last row of the tree. Example  Leftmost value in the last row of first binary tree is 2 and of second binary tree is 6. Breadth First Search In Breadth First Traversal, the tree is traversed Read More

Binary Tree Right Side View | Tree Problem | LeetCode 199

4 years ago Lalit Bhagtani 0
Problem Statement Imagine you are standing on the right side of a binary tree, Write a program to return the values of all the nodes that you can see ordered from top to bottom. Example  The right side view of above binary tree shows nodes.  Breadth First Search In Breadth First Read More

Minimum Depth of Binary Tree | Tree Problem | LeetCode 111

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, write a program to find out its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node of the binary tree to its nearest leaf node. Example  In above binary tree, the shortest path from root node to its Read More

Insert into a Binary Search Tree | Tree Problem | LeetCode 701

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary search tree and a value V, insert the value V into the binary search tree and return the root node of the modified BST. It is guaranteed that the value V does not exist in the BST. Example  Inserting 7 into above binary search tree. Solution To solve Read More

Average of Levels in Binary Tree | Tree Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, return the average of all the nodes values on each level in the form of a list. Example  Average value of nodes on level 0 is 3, on level 1 is 14.5, on level 2 is 7.5 and on level 3 is 4.6. So result is Read More

Level Order Traversal of Binary Tree | Tree Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, return the level order traversal of its node values. In level order traversal, we traverse a binary tree from left to right and level by level. Example  Level order traversal of above binary tree is     Algorithm  In Read More

Minimum Distance Between BST Nodes in Java | Tree Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary search tree, find out the minimum difference between the values of any two nodes in the tree. Example  Difference between node 16 & 17, 17 & 18 is minimum in above binary search tree. So result is 1.   Algorithm  InOrder traversal of binary search tree returns the list Read More

PreOrder Traversal of Tree in Java | Tree Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, return the preorder traversal of its node values. Example  Preorder traversal of above binary tree is   Algorithm  Preorder traversal is also known as prefix traversal. In preorder traversal, we recursively process all the nodes of a tree. Read More

InOrder Traversal of Tree in Java | Tree Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a binary tree, return the inorder traversal of its node values. Example  In order traversal of above binary tree is   Algorithm  Inorder traversal is also known as infix traversal. In inorder traversal, we recursively process all the nodes of a Read More