Given an array of tuples (val, parent_idx) where val is the value of a node in a tree and parent_indx represents index of it's parent in the given array.
Index: 0 1 2 3 4 5 6 7 8
Original : (1,0) (2, 0) (4, 0) (8,2) (9, 2) (6, 2) (5, 2) (3,3) (7,7)
Node to delete: idx: 2
The parent of any element at index i is in range [0...i]
The above represents the following tree
1
/ \
2 4
8 9 6 5
3
7Output : (1,0) (2, 0) (8,0) (9, 2) (6, 2) (5, 2) (3,2) (7,6)
1
/ \
2 8
3 9 6 5
7