Database Reference
In-Depth Information
A1.2.5 Implementation of Binary Trees
Suppose that you desire a binary tree of LibraryPatron objects. The LibraryPatron class
includes data items including patron number, name, major, and status; it also includes
methods for manipulating instances of the class. You can implement this tree using an
array, array-list, or linked-list. The preference is for the linked-list implementation, since
it provides more flexibility. Figure A1-5 shows the UML diagrams for implementing this
binary tree. It is assumed that you have mastery of fundamental programming principles;
therefore, elaboration on these diagrams is not considered necessary. Note also that
Figure A1-5c lists a number of methods that you may choose to implement. Except for
traversal methods (the last three), you should be able to figure out the required logic for
these methods ob your own. Figure A1-6 provides the pseudo-code for these methods.
The logic for the traversal methods will be discussed in the next subsection.
Figure A1-5a. The UML Diagram of the LibraryPatron Class
Figure A1-5b. The UML Diagram of the PatronNode Class
 
Search WWH ::




Custom Search