set( { set constructor {kk+ for in { dict(zip( [ len( )){ dict fromkeys( { dict comprehension dict constructor dict method so why bother with custom search data structure implementation heregiven such flexible built-insin some applicationsyou might notbut here especiallya custom implementation often makes sense to allow for customized tree algorithms for instancecustom tree balancing can help speed lookups in pathological casesand might outperform the generalized hashing algorithms used in dictionaries and sets moreoverthe same motivations we gave for custom stacks and sets apply here as well--by encapsulating tree access in class-based interfaceswe support future extension and change in more manageable ways implementing binary trees binary trees are named for the implied branch-like structure of their subtree links typicallytheir nodes are implemented as triple of values(leftsubtreenodevaluerightsubtreebeyond thatthere is fairly wide latitude in the tree implementation here we'll use class-based approachbinarytree is header objectwhich initializes and manages the actual tree emptynode is the empty objectshared at all empty subtrees (at the bottombinarynode objects are nonempty tree nodes with value and two subtrees instead of coding distinct search functionsbinary trees are constructed with "smartobjects--class instances that know how to handle insert/lookup and printing requests and pass them to subtree objects in factthis is another example of the object-oriented programming (oopcomposition relationship in actiontree nodes embed other tree nodes and pass search requests off to the embedded subtrees single empty class instance is shared by all empty subtrees in binary treeand inserts replace an empty node with binarynode at the bottom example - shows what this means in code example - pp \dstruct\classics\btree py " valueless binary search treeclass binarytreedef __init__(self)def __repr__(self)def lookup(selfvalue)def insert(selfvalue) data structures self tree emptynode(return repr(self treereturn self tree lookup(valueself tree self tree insert(value