摘要: 1.二叉树转链表Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:1 \ 2 \ 3 \ 4 \ 5 \ ... 阅读全文
posted @ 2013-05-09 22:35 代码改变未来 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 二叉树层序遍历,然后串成一个单链表,不允许用队列,要求空间复杂度为常数struct Node { int value; Node *left; Node *right; Node *next;};Node *Func(Node *root) { if (NULL == root) return NULL; Node *p1 = root, *p2 = root; p2->next = p2->left; if (NULL != p2->left) { p2->left->next = p2->right; els... 阅读全文
posted @ 2013-05-09 14:31 代码改变未来 阅读(236) 评论(0) 推荐(0) 编辑