python implementation of linked binary tree structure in this sectionwe define concrete linkedbinarytree class that implements the binary tree adt by subclassing the binarytree class our general approach is very similar to what we used when developing the positionallist in section we define simplenonpublic node class to represent nodeand public position class that wraps node we provide validate utility for robustly checking the validity of given position instance when unwrapping itand make position utility for wrapping node as position to return to caller those definitions are provided in code fragment as formalitythe new position class is declared to inherit immediately from binarytree position technicallythe binarytree class definition (see code fragment does not formally declare such nested classit trivially inherits it from tree position minor benefit from this design is that our position class inherits the ne special method so that syntax ! is derived appropriately relative to eq our class definition continuesin code fragment with constructor and with concrete implementations for the methods that remain abstract in the tree and binarytree classes the constructor creates an empty tree by initializing root to none and size to zero these accessor methods are implemented with careful use of the validate and make position utilities to safeguard against boundary cases operations for updating linked binary tree thus farwe have provided functionality for examining an existing binary tree howeverthe constructor for our linkedbinarytree class results in an empty tree and we have not provided any means for changing the structure or content of tree we chose not to declare update methods as part of the tree or binarytree abstract base classes for several reasons firstalthough the principle of encapsulation suggests that the outward behaviors of class need not depend on the internal representationthe efficiency of the operations depends greatly upon the representation we prefer to have each concrete implementation of tree class offer the most suitable options for updating tree the second reason we do not provide update methods in the base class is that we may not want such update methods to be part of public interface there are many applications of treesand some forms of update operations that are suitable for one application may be unacceptable in another howeverif we place an update method in base classany class that inherits from that base will inherit the update method considerfor examplethe possibility of method replace(pethat replaces the element stored at position with another element such general method may be unacceptable in the context of an arithmetic expression tree (see example on page and later case study in section )because we may want to enforce that internal nodes store only operators as elements