For class I have a project to do. Basically its to take a BST and put it into a 1d array.
so its like insert 5,3,8,,1,4,9
the array will look like 5 3 8 1 4 -1 9
so the BST works as 5 is the root then you multiply 1 since it is in spot 1 by 2 and you get the next number that is less than the root. and to put the 8 in spot 3 you take 5 in spot 1 and multiply 1*2+1.
what im confused about is if I want to take the 8 out that means the 9 has to move up. to its spot since its the next in line and needs to be connected to 5
so now you have 5
/ \
3 9
so if you have 5
\
8
\
9
/
6
and you want to remove the 8. so the 9 and the 6 have to come up. how would you right that code to move both of them up. it needs to be code that would move however long the tree is and whatever it looks like. so It needs to go to the end and check both sides of each number