Skip to content
Advertisement

Python – Tree without classes

How can I implement a tree without using classes in python? I can only use lists, dictionaries and queue. Obviously without the library bintree.

Advertisement

Answer

I usually use defaultdict:

JavaScript

Usage:

JavaScript

bonus: Maria Callas singing O Mio Babbino Caro

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement