[Python] Determinazione altezza albero
Dario Bertini
berdario a gmail.com
Gio 5 Dic 2013 00:54:31 CET
>>> tree=((),((),((),((),(),((),)))),((),()))
>>> tree
((), ((), ((), ((), (), ((),)))), ((), ()))
>>> def height(tree):
... if len(tree) == 0:
... return 1
... else:
... return 1+max(map(height, tree))
...
>>> height(tree)
6
--
xmpp: berdario at gmail.com
bitmessage: BM-2cTYXfGiSTsnx3righ6aHcJSWe4MV17jDP
gpg fingerprint: 3F8D53518012716C4EEF7DF67B498306B3BF75A0 (used just
for signing commits)
Maggiori informazioni sulla lista
Python