Inactive Tutor answered 12/04/20
//utility function
node* newnode(string input) {
node* beep = new node;
beep->data = input;
return beep;
}
//insertion into binary tree
node* push(node* root,string toAdd) {
if (root == nullptr) return newnode(toAdd);
if (toAdd < root->data) {
root->left = push(root->left, toAdd);
}
else {
root->right = push(root->right, toAdd);
}
return root;
}
//main driver code
string Arr[]
int size = (size of array)
node* head = newnode(Arr[0]);
for(int i=1;i<size;i++){
push(head,Arr[i]);
}
//this is written in c++, dm me to convert it to java or python
Inactive Tutor
also you can change it from string to int or you can change what the BST tree sorts by in the push function12/04/20