Redian新闻
>
merge two Binary search tree in O(n) time and O(1) space
avatar
merge two Binary search tree in O(n) time and O(1) space# Programming - 葵花宝典
c*t
1
Hi, I am posting this for my friend. She is a Native English speaker and
looking for an English tutoring job.If you are interested, please pm or
reply here. I will contact with you soon.Thanks!
您好, 我替我朋友发这个贴子. 她是老美,正在找一个教英文的工作.如果你有兴趣,请
给我站内发短信.谢谢.我会尽快与您联系.
avatar
H*M
2
that excludes recursion..
can not think of how to...
any ideas?
dsw algorthm by tree rotation?
Thanks!
avatar
X*r
3
Traversing a binary search tree is O(n) time and O(1) space, right?
Just to traverse two trees together, removing nodes from one tree
and insert them into the right place of the other, like merge sort.

【在 H*M 的大作中提到】
: that excludes recursion..
: can not think of how to...
: any ideas?
: dsw algorthm by tree rotation?
: Thanks!

avatar
H*M
4
traversing a binary search tree is O(1) space? how?
if recursion ->no
if iterative, need stack a...

【在 X****r 的大作中提到】
: Traversing a binary search tree is O(n) time and O(1) space, right?
: Just to traverse two trees together, removing nodes from one tree
: and insert them into the right place of the other, like merge sort.

avatar
X*r
5
This assumes every node in the tree has a pointer to its parent.
To find the next ndoe of current node: if the current node has right
child, return the left-most descendant of the right child; otherwise
return the parent of the current node.

【在 H*M 的大作中提到】
: traversing a binary search tree is O(1) space? how?
: if recursion ->no
: if iterative, need stack a...

avatar
H*M
6
oh...i forgot to mention...no parent pointer in the Node data structure..

【在 X****r 的大作中提到】
: This assumes every node in the tree has a pointer to its parent.
: To find the next ndoe of current node: if the current node has right
: child, return the left-most descendant of the right child; otherwise
: return the parent of the current node.

avatar
y*i
7
你这个算法是 O(nlogn)

【在 X****r 的大作中提到】
: Traversing a binary search tree is O(n) time and O(1) space, right?
: Just to traverse two trees together, removing nodes from one tree
: and insert them into the right place of the other, like merge sort.

avatar
r*o
8
what is dsw algorithm?

【在 H*M 的大作中提到】
: that excludes recursion..
: can not think of how to...
: any ideas?
: dsw algorthm by tree rotation?
: Thanks!

avatar
H*M
9
plz google. or I posted a link of the original paper in jobhunting board..

【在 r****o 的大作中提到】
: what is dsw algorithm?
avatar
z*e
10
瞟了一眼那个dsw算法,嗯,写paper真的要很能绕...
应该是差不多的做法,你把两个tree都用那个tree_to_vine变成一个基本上sorted的
list,然后就很好merge了,然后剩下就是又用那个vine_to_tree变回到balanced tree
(或者就不管了)。

【在 H*M 的大作中提到】
: plz google. or I posted a link of the original paper in jobhunting board..
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。