Trees/OOP
From charlesreid1
Tree data structures provide a great application of many object-oriented programming principles.
Abstract class interfaces allow you to impose a uniform interface for different tree types or tree implementations, and have it all be transparent to the user.
Template method pattern is a pattern that involves creating functional hooks (before/after hooks), so-called "template methods". These are useful for doing things like customizing a tree traversal.
Generic type/template interfaces are useful for storing arbitrary data in trees - templated tree node classes are useful because the data stored in the tree is not usually material to the schema of the tree itself.
Comparison operator implementation and overloading comparison operator behavior for objects is also extremely useful to be able to do, as it allows you to perform comparisons to store sorted trees.
Exceptions are a must. Proper exception handling, and good exception-handling practices, can be practiced with trees.
See also: OOP Checklist
Flags
Trees Part of Computer Science Notes
Series on Data Structures Abstract data type: Trees/ADT Concrete implementations: Trees/LinkedTree · Trees/ArrayTree · SimpleTree
Tree Traversal Preorder traversal: Trees/Preorder Postorder traversal: Trees/Postorder In-Order traversal: Binary Trees/Inorder Breadth-First Search: BFS Breadth-First Traversal: BFT Depth-First Search: DFS Depth-First Traversal: DFT OOP Principles for Traversal: Tree Traversal/OOP · Tree Traversal/Traversal Method Template Tree operations: Trees/Operations Performance · Trees/Removal
Tree Applications Finding Minimum in Log N Time: Tree/LogN Min Search
Abstract data type: Binary Trees/ADT Concrete implementations: Binary Trees/LinkedBinTree · Binary Trees/ArrayBinTree Binary Trees/Cheat Sheet · Binary Trees/OOP · Binary Trees/Implementation Notes
|