Abstract
Balancing a binary tree is the infamous interview problem that has all that folklore and debate associated with it. To tell you the truth, like the other 99% of programmers, I never had to perform this task for some work-related project. And not even due to the existence of ready-made libraries, but because self-balancing binary trees are, actually, pretty rarely used. But trees, in general, are ubiquitous even if you may not recognize their presence. The source code we operate with, at some stage of its life, is represented as a tree (a popular term here is Abstract Syntax Tree or AST, but the abstract variant is not the only one the compilers process). The directory structure of the filesystem is the tree. The object-oriented class hierarchy is likewise. And so on. So, returning to interview questions, trees indeed are a good area as they allow to cover a number of basic points: linked data structures, recursion, and complexity. But there’s a much better task, which I have encountered a lot in practice and also used quite successfully in the interview process: breadth-first tree traversal. We’ll talk about it a bit later.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
This statement is strictly true for balanced trees, but, even for imbalanced trees, such estimation is usually correct.
- 2.
Although it was shown that this value may also be reduced to a single bit if the tree is implemented as a rank balanced tree with delta ranks allowed of 1 or 2 meaning “when going upward there is an additional increment in height of one or two.”
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2021 Vsevolod Domkin
About this chapter
Cite this chapter
Domkin, V. (2021). Trees. In: Programming Algorithms in Lisp. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-6428-7_9
Download citation
DOI: https://doi.org/10.1007/978-1-4842-6428-7_9
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-6427-0
Online ISBN: 978-1-4842-6428-7
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)