Quantcast
Channel: Guan Gui » tree traversal
Browsing all 10 articles
Browse latest View live

LeetCode in Swift: Binary Tree Postorder Traversal

Problem Statement Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial,...

View Article



LeetCode in Swift: Binary Tree Inorder Traversal

Problem Statement Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solution is trivial, could...

View Article

LeetCode in Swift: Binary Tree Preorder Traversal

Problem Statement Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could...

View Article

LeetCode in Swift: Binary Tree Level Order Traversal

Problem Statement Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \...

View Article

LeetCode in Swift: Binary Tree Level Order Traversal II

Problem Statement Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree...

View Article


LeetCode in Swift: Binary Tree Postorder Traversal

Problem Statement Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial,...

View Article

LeetCode in Swift: Binary Tree Inorder Traversal

Problem Statement Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solution is trivial, could...

View Article

LeetCode in Swift: Binary Tree Preorder Traversal

Problem Statement Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could...

View Article


LeetCode in Swift: Binary Tree Level Order Traversal

Problem Statement Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \...

View Article


LeetCode in Swift: Binary Tree Level Order Traversal II

Problem Statement Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree...

View Article
Browsing all 10 articles
Browse latest View live




Latest Images