Skip to main content

Introduction

  • hierarchical data structure
  • Terms related to tree:
    1. root
    2. leaf - nodes with no children
    3. children
    4. parent
    5. subtree
    6. descendants
    7. ancestors
    8. degree - no of children
    9. 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
class Node:
def __init__(self. k):
self.left = None
self.right = None
self.val = k