摘要: 把二元查找树转变成排序的双向链表题目:输入一棵二元查找树,将该转换成个排 序的双向链表。要求不能创建任何新的结点,只调整指针向。 10 / \ 6 14 / \ / \ 4 8 12 8转换成双向链表4=6=8=10=12=14=16 利用中序遍历来解决比较简单,这里我主要提供一种非递归版本来解决这 阅读全文
posted @ 2016-02-28 16:32 sdlwlxf 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Subscribe to see which companies asked this question 阅读全文
posted @ 2016-02-28 14:23 sdlwlxf 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 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 \ 2 \ 3 \ 4 阅读全文
posted @ 2016-02-28 13:04 sdlwlxf 阅读(167) 评论(0) 推荐(0) 编辑