#P1367. Day5 树与贪心综合完善(10题)
Day5 树与贪心综合完善(10题)
第 1 题
完善统计叶子函数:空树返回什么?
if (!root) return ____;
{{ input(1) }}
第 2 题
完善统计叶子函数:当前结点为叶子时返回什么?
if (!root->left && !root->right) return ____;
{{ input(2) }}
第 3 题
完善统计叶子函数:填写左子树递归调用。
return ____ + countLeaf(root->right);
{{ input(3) }}
第 4 题
完善 BST 插入:x 较小时递归插入左子树。
root->left = ____;
{{ input(4) }}
第 5 题
完善 BST 插入:x 较大时递归插入右子树。
root->right = ____;
{{ input(5) }}
第 6 题
完善层序遍历:读取队首结点。
Node* u = ____;
{{ input(6) }}
第 7 题
完善层序遍历:删除已读取的队首结点。
Node* u = q.front();
____;
{{ input(7) }}
第 8 题
完善层序遍历:将左孩子加入队列。
if (u->left) ____;
{{ input(8) }}
第 9 题
哈夫曼合并两个最小结点 x、y,新权值应填什么?
z.weight = ____;
{{ input(9) }}
第 10 题
每次取最大面额硬币是否对所有硬币系统都能得到最少硬币数?
{{ select(10) }}
- 一定能
- 不一定能