Courses
Tutorials
Practice
Data Structure
Java
Python
HTML
Interview Preparation
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
SQL
Web Development
System Design
Aptitude
GfG Premium
Similar Topics
Web Technologies
37.4K+ articles
DSA
22.8K+ articles
Mathematical
7.8K+ articles
Searching
1.7K+ articles
Tree
1.4K+ articles
Recursion
1.0K+ articles
Queue
371+ articles
DFS
359+ articles
Binary Tree
330+ articles
tree-level-order
123+ articles
Tree Traversals
106+ posts
Recent Articles
Popular Articles
Maximum absolute difference between any two level sum in a N-ary Tree
Last Updated: 30 January 2023
Given an N-ary Tree having N nodes with positive and negative values and (N - 1) edges, the task is to find the maximum absolute difference of level sum in it.Examples:Inp...
read more
Tree
Queue
Searching
C++
DSA
BFS
Tree Traversals
Count pairs of nodes having minimum distance between them equal to the difference of their distances from root
Last Updated: 16 September 2021
Given an N-ary Tree consisting of N nodes valued from [1, N], where node 1 is the root, the task is to count the pairs of nodes having minimum distance between them equal ...
read more
Misc
Tree
Searching
Mathematical
Recursion
DSA
Binary Tree
DFS
Tree Traversals
Preorder, Postorder and Inorder Traversal of a Binary Tree using a single Stack
Last Updated: 18 January 2022
Given a binary tree, the task is to print all the nodes of the binary tree in Pre-order, Post-order, and In-order iteratively using only one stack traversal.Examples:Input...
read more
Tree
Stack
Algorithms
DSA
Inorder Traversal
Preorder Traversal
PostOrder Traversal
Binary Tree
Tree Traversals
cpp-stack
Maximize sum of path from the Root to a Leaf node in N-ary Tree
Last Updated: 23 November 2024
Given a generic tree consisting of n nodes, the task is to find the maximum sum of the path from the root to the leaf node.Examples:Input:Output: 12Explanation: The path s...
read more
Misc
Tree
Mathematical
Recursion
DSA
DFS
Tree Traversals
n-ary-tree
Print all the paths from root to leaf, with a specified sum in Binary tree
Last Updated: 07 December 2024
Given a Binary tree and target sum, the task is to find all the possible paths from root to leaf that have the sum equal to the given sum.ExamplesInput: Output: [[10, 28]...
read more
Tree
Stack
Recursion
DSA
DFS
Tree Traversals
Left and Right view of a Generic Tree
Last Updated: 12 December 2022
Given a Generic Tree consisting of N nodes, the task is to find the left and right views of the given generic Tree.Examples:Input: 1 / \ 2 3 ...
read more
Misc
Tree
Queue
DSA
Tree Traversals
tree-level-order
Minimum distance between two given nodes in an N-ary tree
Last Updated: 16 September 2021
Given a N ary Tree consisting of N nodes, the task is to find the minimum distance from node A to node B of the tree.Examples:Input: 1 / \ 2 3 ...
read more
Misc
Tree
DSA
Tree Traversals
n-ary-tree
Create a wave array from the given Binary Search Tree
Last Updated: 25 February 2022
Given a Binary Search Tree, the task is to create a wave array from the given Binary Search Tree. An array arr[0..n-1] is called a wave array if arr[0] = arr[1] = arr[2] =...
read more
Tree
Mathematical
Binary Search Tree
DSA
Arrays
Inorder Traversal
BST
tree-traversal
Tree Traversals
Flatten a Binary Search Tree to convert the tree into a wave list in place only
Last Updated: 27 December 2022
Given a Binary Search Tree consisting of N distinct nodes, the task is to flatten the given Binary Search Tree to convert the tree into a wave list. A wave list arr[0..n-1...
read more
Tree
Binary Search Tree
DSA
Inorder Traversal
BST
tree-traversal
Tree Traversals
Binary Tree Iterator for Inorder Traversal
Last Updated: 20 February 2023
Given a Binary Tree and an input array. The task is to create an Iterator that utilizes next() and hasNext() functions to perform Inorder traversal on the binary tree.Exam...
read more
Tree
Algorithms
DSA
Inorder Traversal
Binary Tree
cpp-iterator
Tree Traversals
Binary Search Tree (BST) Traversals – Inorder, Preorder, Post Order
Last Updated: 21 August 2024
Given a Binary Search Tree, The task is to print the elements in inorder, preorder, and postorder traversal of the Binary Search Tree. Input: A Binary Search TreeOutput: I...
read more
Binary Search Tree
Recursion
Picked
DSA
Tree Traversals
Preorder Traversal of Binary Tree
Last Updated: 28 March 2025
Preorder traversal is a tree traversal method that follows the Root-Left-Right order:The root node of the subtree is visited first.Next, the left subtree is recursively tr...
read more
Tree
DSA
Binary Tree
Tree Traversals
Time and Space Complexity Analysis of Tree Traversal Algorithms
Last Updated: 31 May 2023
Let us discuss the Time and Space complexity of different Tree Traversal techniques, such as Inorder Traversal, Preorder Traversal, Postorder Traversal, etc.Time Complexit...
read more
Tree
DSA
Inorder Traversal
Preorder Traversal
PostOrder Traversal
tree-traversal
Data Structures-Tree Traversals
Tree Traversals
Complexity-analysis
Tree Traversal Techniques in Python
Last Updated: 22 January 2024
A tree is a non-linear data structure or we can say that it is a type of hierarchical structure. It is like an inverted tree where roots are present at the top and leaf or...
read more
Python
Picked
Tree Traversals
Python-DSA
POTD Solutions | 20 Nov’ 23 | K Sum Paths
Last Updated: 28 April 2025
View all POTD SolutionsWelcome to the daily solutions of our PROBLEM OF THE DAY (POTD). We will discuss the entire problem step-by-step and work towards developing an opti...
read more
Competitive Programming
DSA
Binary Tree
Tree Traversals
GFG-POTD-Solutions
1
2
3
4
5
6
7
8
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our
Cookie Policy
&
Privacy Policy
Got It !