Re:Ask HN: Have you ever needed to invert a binary tree at w...
by kazinator on Saturday May 22, 2021 @01:15AM
(#27243714)
Inverting a binary tree doesn't achieve anything; the organization is basically the same, being a mirror image, and so doesn't shed any new light on the data.
If you ever have to maintain a code base that happens to invert binary trees, find a way to nuke that code. Whatever needs the binary tree backwards should just process the original order backwards. Then you can say you once needed to remove a silly binary tree inversion at work.
Even reversing arrays and linked lists is suspicious.
Lisp code sometimes does a nreverse pass due to pushing items onto a stack while processing, which reverses their order.
I've never had to reverse an array in C or what have you.
I recall that the block sort algorithm does some clever things with multiple reverses of subranges of an array.
If you ever have to maintain a code base that happens to invert binary trees, find a way to nuke that code. Whatever needs the binary tree backwards should just process the original order backwards. Then you can say you once needed to remove a silly binary tree inversion at work.
Even reversing arrays and linked lists is suspicious.
Lisp code sometimes does a nreverse pass due to pushing items onto a stack while processing, which reverses their order.
I've never had to reverse an array in C or what have you.
I recall that the block sort algorithm does some clever things with multiple reverses of subranges of an array.