avatar
HP home Shipped!# PDA - 掌中宝
r*o
1
一种方法是用queue和stack,还有别的方法吗?
avatar
B*g
2
不要把F5,ctrl+r按坏了
不要拿着140的approval notice老看容易看坏,就是看也别撮PD那一嘎的
avatar
h*a
3
谢谢
avatar
s*g
4
估计窦文涛也没见过几个这么不配合的嘉宾哈哈
avatar
r*1
6
但是给的 tracking number 还显示 not found!
avatar
s*t
7
你是说倒着的BFS?
avatar
n*s
8
LOL.
avatar
r*o
9
是啊,怎么打印比较好?

【在 s******t 的大作中提到】
: 你是说倒着的BFS?
avatar
f*u
10
对啊,看看自己是不是EB2,别像以前版上的人,快到了才发现自己是EB3.
avatar
s*t
11
正常bfs打印到一个临时的buffer中,然后从buf打出倒序?
p
avatar
c*h
12
你的到了没?
avatar
s*a
13
用queue
要visit的从dequeue
fringe node enqueue
直到所有的都遍历完

【在 r****o 的大作中提到】
: 是啊,怎么打印比较好?
avatar
B*g
14
不敢看,怕是EB3

【在 c*h 的大作中提到】
: 你的到了没?
avatar
r*o
15
要visit的从dequeue是什么意思

【在 s********a 的大作中提到】
: 用queue
: 要visit的从dequeue
: fringe node enqueue
: 直到所有的都遍历完

avatar
c*h
16
LOL

【在 B*****g 的大作中提到】
: 不敢看,怕是EB3
avatar
l*g
17
一个queue应该就可以了,我把code贴出来了。如果有错误的话,请指正。
printByLevel(Node *root)
{
Queue queue;
int currLevel = 1; /* total number of nodes on the current level */
int currPos = 0; /* current position on the current level */
int nextLevel = 0; /* total number of nodes on the next level */
queue.enqueue(root);
while(currLevel>0)
{
Node *curr = queue.dequeue();
printNode(curr);
if(curr->left){
queue.enqueue(curr->left);
nextL
avatar
s*t
18
他的意思是要反向打印
比如:
a
b c
d e f g
打印成
d e f g
b c
a

*/
*/

【在 l*******g 的大作中提到】
: 一个queue应该就可以了,我把code贴出来了。如果有错误的话,请指正。
: printByLevel(Node *root)
: {
: Queue queue;
: int currLevel = 1; /* total number of nodes on the current level */
: int currPos = 0; /* current position on the current level */
: int nextLevel = 0; /* total number of nodes on the next level */
: queue.enqueue(root);
: while(currLevel>0)
: {

avatar
c*f
19
是不是用1个queue一个deque?
avatar
r*o
20
自己顶一下。

【在 r****o 的大作中提到】
: 一种方法是用queue和stack,还有别的方法吗?
avatar
r*o
21
请各位大牛出招啊。

【在 r****o 的大作中提到】
: 一种方法是用queue和stack,还有别的方法吗?
avatar
s*t
22
queue或者stack不是挺好的么?为啥一定要其他的?转化成递归?我不sure是不是能做
。。。没仔细想过。
BTW:我不是大牛。。。。我是打酱油的。

【在 r****o 的大作中提到】
: 请各位大牛出招啊。
avatar
r*o
23
以前看到过版上的牛人讨论过一个很好的方法,找不到链接了。

【在 s******t 的大作中提到】
: queue或者stack不是挺好的么?为啥一定要其他的?转化成递归?我不sure是不是能做
: 。。。没仔细想过。
: BTW:我不是大牛。。。。我是打酱油的。

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