I am not hiding this is a part of my homework but I've tried enough before posting here.
So...
I need to prove for a binary tree that a node k have its left child on 2k and right child on 2k + 1 position. I've proved this with induction.
Now I need to prove for a binary tree that a node k have its parent on (floor)(k/2)
position. I took two cases.
Tried it with induction as well. It's true for a tree of 3 nodes.
If it's true for node k I'll prove for node k + 1.
- If node k+1 shares parent with node k it's obviously true.
- If node k+1 has difference parent with node k....
I am trying to make a general binary tree but the types won't help me to use induction assumption. I assume maybe I'll have to use what I proved before for child's position.
Any help?