News for hackers. Stuff that matters.
Re:The ancient world before computers had stacks or heaps by Arnavion on Wednesday April 03, 2024 @01:01PM (#39919945)
Tree traversal uses stacks / queues unless you're dealing with a small tree such that you're sure recursion won't blow your stack, or your algorithm can work with tail calls and your language guarantees TCO.
Re:The ancient world before computers had stacks or heaps by josephg on Wednesday April 03, 2024 @04:00PM (#39922315)
Any balanced tree will be shallow enough that this isn't a problem in practice. You'll run out of RAM / hard disk space to store your tree before you run out of stack space.
Re:The ancient world before computers had stacks or heaps by Arnavion on Wednesday April 03, 2024 @04:25PM (#39922615)
There are lots of trees that can't be balanced, like tries.