Redian新闻
>
请教一个binary search tree和heap的问题。
avatar
请教一个binary search tree和heap的问题。# JobHunting - 待字闺中
C*n
1
问个很基本的问题。
假定某个binary search tree和max heap都是有输入一些数字序列所构成,
那么是不是binary search tree跟输入数字的顺序无关,只可能有一种binary search
tree,
但max heap(或min heap)则跟输入数字的顺序有关,同样的几个数字,输入顺序不同所
形成的max heap也不一样?
avatar
a*s
2
都有关
avatar
C*n
3
是吗?
那如果我看到书上一个现成的binary search tree,
请问该按什么顺序输入这些数字才能使得所生成的binary search tree跟书上的那个一
样呢?

【在 a**********s 的大作中提到】
: 都有关
avatar
a*s
4
就是的, 如果无关, 那还问你这个干吗?

【在 C**********n 的大作中提到】
: 是吗?
: 那如果我看到书上一个现成的binary search tree,
: 请问该按什么顺序输入这些数字才能使得所生成的binary search tree跟书上的那个一
: 样呢?

avatar
C*n
5
那你能说一下怎样输入这些数字才能使得生成的binary search tree跟我想要的那个一
样呢?

【在 a**********s 的大作中提到】
: 就是的, 如果无关, 那还问你这个干吗?
avatar
s*l
6
Preorder traversal

【在 C**********n 的大作中提到】
: 那你能说一下怎样输入这些数字才能使得生成的binary search tree跟我想要的那个一
: 样呢?

avatar
g*y
7
很多种输入方法。一种是按照已知tree的pre-order输入

【在 C**********n 的大作中提到】
: 那你能说一下怎样输入这些数字才能使得生成的binary search tree跟我想要的那个一
: 样呢?

avatar
C*n
8
thanks a lot.

【在 g*******y 的大作中提到】
: 很多种输入方法。一种是按照已知tree的pre-order输入
avatar
S*Y
9
all are related
preOrder traversal or level order traveral

search

【在 C**********n 的大作中提到】
: 问个很基本的问题。
: 假定某个binary search tree和max heap都是有输入一些数字序列所构成,
: 那么是不是binary search tree跟输入数字的顺序无关,只可能有一种binary search
: tree,
: 但max heap(或min heap)则跟输入数字的顺序有关,同样的几个数字,输入顺序不同所
: 形成的max heap也不一样?

avatar
C*n
10
呵呵,
那给定一些数字,我想构造一个Max heap或Min heap,
那按level order traveral能否构找出我想要的那个Max heap?

【在 S**Y 的大作中提到】
: all are related
: preOrder traversal or level order traveral
:
: search

avatar
S*Y
11
the "level order traversal" of a heap is the order of the array inside the h
eap. Of course you can copy the array...

【在 C**********n 的大作中提到】
: 呵呵,
: 那给定一些数字,我想构造一个Max heap或Min heap,
: 那按level order traveral能否构找出我想要的那个Max heap?

avatar
C*n
12
what do you mean the order of the array inside the heap?

h

【在 S**Y 的大作中提到】
: the "level order traversal" of a heap is the order of the array inside the h
: eap. Of course you can copy the array...

avatar
S*Y
13
normally heap is implemented by an array..

【在 C**********n 的大作中提到】
: what do you mean the order of the array inside the heap?
:
: h

avatar
C*n
14
OK, I got it.

【在 S**Y 的大作中提到】
: normally heap is implemented by an array..
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。