Introduction
- hierarchical data structure
- Terms related to tree:
- root
- leaf - nodes with no children
- children
- parent
- subtree
- descendants
- ancestors
- degree - no of children
- internal nodes - non-leaf nodes
Applications: organization structure; folder structure; XML/HTML content; binary search tree; binary heap; b and B+ tree
info
We mainly talk and study about binary trees.
Binary Tree
- at most 2 children
- Python
class Node:
def __init__(self. k):
self.left = None
self.right = None
self.val = k