#10428. szjy_6_树_048
szjy_6_树_048
szjy_6_树_048
给定的树是一棵二叉搜索树。阅读代码,程序输出是( )。
#include <iostream>
using namespace std;
struct Node {
int value;
Node* left = nullptr;
Node* right = nullptr;
};
int minValue(Node* root) {
while (root->left != nullptr) root = root->left;
return root->value;
}
int main() {
Node a{15}, b{6}, c{23}, d{4}, e{7}, f{18}, g{71};
a.left = &b; a.right = &c;
b.left = &d; b.right = &e;
c.left = &f; c.right = &g;
cout << minValue(&a);
}
{{ select(1) }}
- 6
- 7
- 15
- 4