* ) * ) * * * ) * * * ) * ) at the end of this we'll see another way to visualize such trees in gui named pytree (you're invited to flip ahead now if you prefernode values in this tree object can be any comparable python object--for instancehere is tree of stringsz binarytree(for in 'badce' insert(cz *' ')' '*' ')' '*' ' binarytree(for in 'abcde' insert(cz *' '*' '*' '*' '*' ' binarytree(for in 'edcba' insert(cz *' ')' ')' ')' ')' 'notice the last tests hereif items inserted into binary tree are already orderedyou wind up with linear structure and lose the search-space partitioning magic of binary trees (the tree grows in right or left branches onlythis is worst-case scenarioand binary trees generally do good job of dividing values in practice but if you are interested in pursuing this topic furthersee data structures text for tree-balancing techniques that automatically keep the tree as dense as possible but are beyond our scope here trees with both keys and values also note that to keep the code simplethese trees store value only and lookups return true or false result in practiceyou sometimes may want to store both key and an associated value (or even moreat each tree node example - shows what such tree object looks likefor any prospective lumberjacks in the audience example - pp \dstruct\classics\btreevals py " binary search tree with values for stored keysclass keyedbinarytreedef __init__(self)def __repr__(self)def lookup(selfkey)def insert(selfkeyval) data structures self tree emptynode(return repr(self treereturn self tree lookup(keyself tree self tree insert(keyval