Если я правильно понимаю ваш код, ожидается переопределение:
void TreeSet::inorderRec(AVLNode *root, int *arr, int pos) {
// lets be pos = 0
if (root) {
inorderRec(root->left, arr, pos); // call with pos = 0
arr[pos++] = root->key; // write to arr[0], then set pos = 1
inorderRec(root->right, arr, pos + 1); // call with pos = 2
}
}
Таким образом, самая левая часть вашего дерева всегда пишет в arr [0].Я ожидаю, что вы только заполняете каждый второй массив новыми значениями.
Может быть, вы хотите использовать указатель на pos?
void TreeSet::inorderRec(AVLNode *root, int *arr, int* pos) {
// lets be pos = 0
if (root) {
inorderRec(root->left, arr, pos); // call with *pos = 0, pos is set to n
arr[(*pos)++] = root->key; // write to arr[n], then set *pos = n+1
*pos = *pos +1;
inorderRec(root->right, arr, pos); // call with *pos = n+2
}
}