Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"invert a binary tree"

This didn't make any sense to me, so I looked it up, and it seems exactly as senseless as I had thought. Is the 'inversion' not the same topology as the input?

my solution: "auto invert(regular_tree x){return static-cast<inverted_tree>(x);}".



When I tried to find what was meant by "invert a binary tree", the only thing that made sense was the operation of reversing the tree: ((1 2) (3 4)) becomes ((4 3) (2 1))


It means swap the left and right pointers for each node.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: