tree traversal
文章平均质量分 78
smallfish_yy
人最幸福的事之一就是把爱好变成自己的工作。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Analysis: 1. Get the middle element of the current array and construct the root with such value.原创 2013-12-25 09:00:02 · 417 阅读 · 0 评论 -
Binary Tree Postorder Traversal
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 solut原创 2014-01-18 05:20:30 · 470 阅读 · 0 评论 -
Binary Tree Level Order Traversal
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原创 2013-12-28 06:31:38 · 423 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
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 {3,9,20,#,#,15,7},原创 2014-01-18 04:14:18 · 387 阅读 · 0 评论 -
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1原创 2014-02-05 02:59:44 · 418 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary原创 2014-02-09 09:32:49 · 415 阅读 · 0 评论 -
Morris Traversal
http://blog.youkuaiyun.com/ithomer/article/category/694817转载 2014-02-22 09:14:31 · 483 阅读 · 0 评论 -
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Analysis: /** * Definition for singly-linked list. * public class ListNode { *原创 2014-02-12 09:09:42 · 480 阅读 · 0 评论
分享