menu_book Course Curriculum (Data Structures & Algorithms) expand_more
Complexity & Foundations
Arrays & Strings
Linked Lists
Stacks & Queues
Hashing
Trees & Heaps
Graphs
Tree height
Learn Tree height in Data Structures & Algorithms with a focused explanation, a topic-specific example, edge guidance, and a mastery check.
12 min read
•
Intermediate
data-structures-algorithms-058.py
python
tree={"l":{"l":None,"r":None},"r":{"l":{"l":None,"r":None},"r":None}}
def height(n): return 0 if n is None else 1+max(height(n["l"]),height(n["r"]))
print(height(tree))
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content