I've come across this python trick of creating a tree:
def Tree(): return defaultdict(Tree) t = Tree() t["key1"]["key2"]["key3"] = value So I'm using it in such a way that each key in this data structure is unique regardless of which dimension I am at. However, this poses a bit of a problem as I want to be able to insert new keys based on a specific parent, e.g I want to insert a child to key3, how do I traverse it in such a way that it finds key3? What strategies/approaches can I take to find a given "key" for example?
I have a feeling this can be solved recursively, but I'm fairly inexperienced with recursion and programming and this is my first attempt at solving a group of groups type problem. Thanks!
valuethat is stored under"key3"? You're turning a leaf into a node - would you just get rid ofvalue?