mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 14:26:29 +08:00
Compare commits
2 commits
4d20fe7b8c
...
58164b22fd
Author | SHA1 | Date | |
---|---|---|---|
|
58164b22fd | ||
|
894e3d536b |
1 changed files with 3 additions and 3 deletions
|
@ -115,9 +115,9 @@ int main() {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int l = abt.left(i), r = abt.right(i), p = abt.parent(i);
|
int l = abt.left(i), r = abt.right(i), p = abt.parent(i);
|
||||||
cout << "\n当前节点的索引为 " << i << ",值为 " << abt.val(i) << "\n";
|
cout << "\n当前节点的索引为 " << i << ",值为 " << abt.val(i) << "\n";
|
||||||
cout << "其左子节点的索引为 " << l << ",值为 " << (l != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
|
cout << "其左子节点的索引为 " << l << ",值为 " << (abt.val(l) != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
|
||||||
cout << "其右子节点的索引为 " << r << ",值为 " << (r != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
|
cout << "其右子节点的索引为 " << r << ",值为 " << (abt.val(r) != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
|
||||||
cout << "其父节点的索引为 " << p << ",值为 " << (p != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
|
cout << "其父节点的索引为 " << p << ",值为 " << (abt.val(p) != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
|
||||||
|
|
||||||
// 遍历树
|
// 遍历树
|
||||||
vector<int> res = abt.levelOrder();
|
vector<int> res = abt.levelOrder();
|
||||||
|
|
Loading…
Reference in a new issue