Feb-11-2020, 04:09 PM
That doesn't strike me as a tree at all. You stated that selecting "b" would take you to the 8th index, which is a "b", but indices 2 and 10 are also "b"; how would this access those?
Plus, there are two strings in the tree that break the str-list-str-list pattern - even if they don't have subnodes, they should still have an empty list for the sake of consistency. This is especially true is you're using indexing to access subsequent subnodes since changes to the pattern will alter the index needed to access all nodes down the line.
Tree structures are complex because there are a variety of checks and behaviors needed to gain the benefits. At a bare minimum, each node needs to be able to contain a value of its own and at least two nodes under it. Try your hand at making a node class that does just that - stores those three attributes. Then, think through how to assign a second node to that one's right or left.
Plus, there are two strings in the tree that break the str-list-str-list pattern - even if they don't have subnodes, they should still have an empty list for the sake of consistency. This is especially true is you're using indexing to access subsequent subnodes since changes to the pattern will alter the index needed to access all nodes down the line.
Tree structures are complex because there are a variety of checks and behaviors needed to gain the benefits. At a bare minimum, each node needs to be able to contain a value of its own and at least two nodes under it. Try your hand at making a node class that does just that - stores those three attributes. Then, think through how to assign a second node to that one's right or left.