Как построить двоичное дерево поиска, читая из файла file.txt - PullRequest
0 голосов
/ 19 апреля 2020

// вставить функцию для вставки значений в BST из заданного набора данных (в данном случае F1.txt) BST * BST :: Insert (BST *root, int value) {if (! root) {/ / Вставьте первый узел, если root равно NULL. вернуть новый BST (значение); }

// Insert data.
if(value > root->data)
{
 // Insert right node data, if the 'value'
 // to be inserted is greater than 'root' node data then 
 // Process right nodes.
 root->right = Insert(root->right, value);
}

else
    {
// Insert left node data, if the 'value'
// to be inserted is greater than 'root' node data then
// Process left nodes.
root->left = Insert(root->left, value);
    }
return root;
}

// I can open the file.txt but I don't know how to call the insert function 
// in the file so I don't have to load values and insert them
// how binary search tree can be constructed by just calling it in the file code 
...