Redian新闻
>
给移民局的支票写成了USCIS,会有问题吗
avatar
给移民局的支票写成了USCIS,会有问题吗# Immigration - 落地生根
B*l
1
12.4 Imagine you have an unbalanced binary search tree. Design an algorithm
which creates a linked list of all the nodes at each depth (eg, if you have
a tree with depth D, you’ll have D linked lists).
答案如下:
struct LLNode {
LLNode(Node* t, LLNode* n) : next(n), tree(t) {}
LLNode* next;
Node* tree;
};
struct ListOfLists {
ListOfLists() : next(NULL), data(NULL) {}
ListOfLists* next;
LLNode* data;
};
ListOfLists* TreeLinkedLists(Node* root) {
ListOfLists* results = new ListOfLists();
traverse(root, results);
return results;
}
void traverse(Node* root, ListOfLists* results) {
if (root == NULL) return; // nothing to do
results->head = new LLNode(root, results->head); // prepend tree node
if (results->next == NULL) {
// extend results if necessary
results->next = new ListOfLists();
}
traverse(root->left, results->next);
traverse(root->right, results->next);
}
traverse函数里这句"results->head = new LLNode(root, results->head);"是不是有
点问题,ListOfLists里没有head这个member啊,那应该怎么改呢?
avatar
r*e
2
一时疏忽, 写成了pay the order of USCIS,会有问题吗, 多谢!
应该是 pay the order of U.S. Department of Homeland Security
avatar
l*a
3
some answers in the book are not good.
why not do it by yourself.
for this problem,
you can fist resolve a issue as "print nodes by level of the BST"
then just create a list of list for each level...

algorithm
have

【在 B******l 的大作中提到】
: 12.4 Imagine you have an unbalanced binary search tree. Design an algorithm
: which creates a linked list of all the nodes at each depth (eg, if you have
: a tree with depth D, you’ll have D linked lists).
: 答案如下:
: struct LLNode {
: LLNode(Node* t, LLNode* n) : next(n), tree(t) {}
: LLNode* next;
: Node* tree;
: };
: struct ListOfLists {

avatar
F*p
4
没有问题
avatar
c*2
5
This is an extension of level order traversal.
If you know how to traverse level by level, this will be easy.
avatar
r*e
6
多谢!
当时因为比较着急寄出去,迷糊了一下.

【在 F**p 的大作中提到】
: 没有问题
avatar
B*l
7
多谢大家,算法方面我是初学者,现在为了面试正在恶补中。我上google看看怎么
traverse tree level by level呢。

【在 c***2 的大作中提到】
: This is an extension of level order traversal.
: If you know how to traverse level by level, this will be easy.

avatar
j*g
8
没问题.只要签字,金额正确.
avatar
A*r
9
没关系。同一个衙门呀。

【在 r****e 的大作中提到】
: 一时疏忽, 写成了pay the order of USCIS,会有问题吗, 多谢!
: 应该是 pay the order of U.S. Department of Homeland Security

avatar
d*1
10
哈! 是一个衙门,精辟
avatar
r*e
11
多谢!

【在 j****g 的大作中提到】
: 没问题.只要签字,金额正确.
avatar
r*e
12
谢谢!

【在 A*********r 的大作中提到】
: 没关系。同一个衙门呀。
avatar
k*e
13
有没有搞错。。。
我一直这么写的啊?
hehe

【在 r****e 的大作中提到】
: 一时疏忽, 写成了pay the order of USCIS,会有问题吗, 多谢!
: 应该是 pay the order of U.S. Department of Homeland Security

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