I need help on binary search tree. I have to use a single array with or without
ID: 3530089 • Letter: I
Question
I need help on binary search tree. I have to use a single array with or without pointers. I am having trouble with the insert function that insert a value element x into BST. Please help. I can not do structures, classes and nodes list. Here what i have that does not work well. int Insert(int x) { int Left; int Right; int parent; for(int i = 1; i < Index; i++) { parent = MyArray[i]; if (x < parent) { Left = x; MyArray[i*2]=x; } else if (x > parent) { Right = x; MyArray[(i/2) + 1] = x; } } return 0; }Explanation / Answer
Please rate with 5 stars :)
Here is an iterative version of how you would insert a node into a BST.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.