You are viewing a single comment's thread. Return to all comments →
The swap operation says: Given a tree and a integer, K, we have to swap the subtrees of all the nodes who are at depth h, where h ∈ [K, 2K, 3K,...].
So - swap 2 will swap levels 2, 4, 6, 8, etc - swap 4 will swap levels 4, 8, 12,
So, in this example, since the tree height is 4, we should have : - swap 2 -> swaps 2 and 4 - swap 4 -> swaps 4
Swap Nodes
You are viewing a single comment's thread. Return to all comments →
The swap operation says: Given a tree and a integer, K, we have to swap the subtrees of all the nodes who are at depth h, where h ∈ [K, 2K, 3K,...].
So - swap 2 will swap levels 2, 4, 6, 8, etc - swap 4 will swap levels 4, 8, 12,
So, in this example, since the tree height is 4, we should have : - swap 2 -> swaps 2 and 4 - swap 4 -> swaps 4