Abstract
By applying object-oriented design to the definition of a binary search tree, Berman and Duvall [1] designed a data structure comprised of three classes: (i) an Emptybst class to model empty binary search trees, (ii) a NonEmptybst class to model non-empty binary search trees, and (iii) a bst base class for common attributes of Emptybst and NonEmptybst objects. That paper noted the problem of inserting new values into such a structure: since insertions occur at an Emptybst object, an Emptybst would have to "turn into" a NonEmptybst; a behavior beyond the capabilities of the classes in most languages.This paper presents three C++ solutions to the insertion problem in their order of development. The first solution uses a procedural programming technique, with the second and third solutions shifting to a more object-oriented approach. This chronology illustrates the author's ongoing battle to shift from procedural to object-oriented thinking.
- 1. A. Michael Berman and Robert C. Duvall, Thinking About Binary Trees In An Object-Oriented World, Proceedings of the 27th SIGCSE Technical Symposium on Computer Science Education, 27(1): 185-189, February, 1996. Google Scholar
Digital Library
- 2. Grady Booch, Object Oriented Design, Benjamin/ Cummings, 1991. Google Scholar
Digital Library
- 3. Bjarne Stroustrup, The C++ Programming Language, Addison-Wesley, 1992, pp. 540. Google Scholar
Digital Library
Index Terms
Knowing your roots: object-oriented binary search trees revisited
Recommendations
Cyclotomic Swan subgroups and primitive roots
Let K"m=Q(@z"m) where @z"m is a primitive mth root of unity. Let p>2 be prime and let C"p denote the group of order p. The ring of algebraic integers of K"m is O"m=Z[@z"m]. Let @L"m","p denote the order O"m[C"p] in the algebra K"m[C"p]. Consider the ...
Computing bounded-degree phylogenetic roots of disconnected graphs
The Phylogenetic kth Root Problem (PRk) is the problem of finding a (phylogenetic) tree T from a given graph G=(V,E) such that (1) T has no degree-2 internal nodes, (2) the external nodes (i.e., leaves) of T are exactly the elements of V, and (3) (u,v)@_...
Computing bounded-degree phylogenetic roots of disconnected graphs
WG'04: Proceedings of the 30th international conference on Graph-Theoretic Concepts in Computer ScienceThe Phylogenetic kth Root Problem (PRk) is theproblem of finding a (phylogenetic) tree T from a given graph G=(V,E) such that (1) T has no degree-2 internal nodes, (2) the external nodes (i.e. leaves) of T are exactly the elements of V, and (3) (u, v) ∈ ...






Comments