07/11/23 14:35:02
>>46
表示順序や二分木表現を書き換えてはいけない、という制限が
無いので木を O(1) 空間でリストに変形すればいい。
void show(node *root) {
node *tail = root;
while (root) {
printf("%d ", root->key);
while (tail->leftchild)
tail = tail->leftchild;
tail->leftchild = root->rightchild;
root = root->leftchild;
}
}