3 ms·
Apparently it means to swap the left and right subtrees. How's that "inversion"? I'd call it "flipping" or "mirroring" or something... If this is the case, then
by discardorama 11y ago
Apparently it means to swap the left and right subtrees. How's that "inversion"? I'd call it "flipping" or "mirroring" or something... If this is the case, then it's a trivial solution: invert(left_child); invert(right_child);
- 59nadir 11y agoOr, if the structure is this: struct node { struct node *left_node; struct node *right_node; int val; }; struct reversed_node { struct reversed_node *right_node; struct reversed_node *left_node; int val; }; No? You then just have a different mapping for the exact same data, no traversal needed.