liuchuo / PAT

🍭 浙江大学PAT题解(C/C++/Java/Python) - 努力成为萌萌的程序媛~
3.37k stars 824 forks source link

[Advanced/C++/1066] bug report #126

Open Dawn-K opened 4 years ago

Dawn-K commented 4 years ago

虽然此题保证了输入数据是互不相同的,但是模板中

root->right = insert(root->right, val);
if (getHeight(root->left) - getHeight(root->right) == -2)
      root = val > root->right->val ? rotateLeft(root) : rotateRightLeft(root);

其中的判断应该修改为val > root->right->val ,否则在多次插入同一个数据时会死循环.

hack数据

5
70 70 70 70 70