mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Bug fixes and improvements (#1581)
* A bug fixes * Sync zh and zh-hant versions. * Fix a question in chapter_array_and_linkedlist/summary.md * Optimize a definition in what_is_dsa.md * Fix the Contributing guidelines for Chinese-to-English. * Add a q&a in chapter_array_and_linkedlist/summary.md * Sync zh and zh-hant versions. * Update .gitignore * Sync zh and zh-hant versions.
This commit is contained in:
@ -115,9 +115,9 @@ int main() {
|
||||
int i = 1;
|
||||
int l = abt.left(i), r = abt.right(i), p = abt.parent(i);
|
||||
cout << "\n當前節點的索引為 " << i << ",值為 " << abt.val(i) << "\n";
|
||||
cout << "其左子節點的索引為 " << l << ",值為 " << (l != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
|
||||
cout << "其右子節點的索引為 " << r << ",值為 " << (r != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
|
||||
cout << "其父節點的索引為 " << p << ",值為 " << (p != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
|
||||
cout << "其左子節點的索引為 " << l << ",值為 " << (abt.val(l) != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n";
|
||||
cout << "其右子節點的索引為 " << r << ",值為 " << (abt.val(r) != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n";
|
||||
cout << "其父節點的索引為 " << p << ",值為 " << (abt.val(p) != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n";
|
||||
|
||||
// 走訪樹
|
||||
vector<int> res = abt.levelOrder();
|
||||
|
||||
Reference in New Issue
Block a user