Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2: Trees - Terminology

Lesson 7 of 14 in the free Data Structure notes on Siksha Sarovar, written by Rohit Jangra.

Introduction to Trees

Trees are Non-Linear, Hierarchical Data Structures where data is organized in parent-child relationships.

Real World Analogy: A computer file system. Root Drive (C:/) → Folders (Parents) → Sub-folders (Children).

Formal Definition: A Tree is a collection of nodes where one node is the Root, and the remaining nodes are partitioned into disjoint sub-trees.

Key Terminology

TermDefinitionExample
RootTopmost node, ancestor of allNode A in most diagrams
EdgeConnection between two nodes (N nodes = N-1 edges)Line from Parent to Child
ParentNode directly above anotherA is parent of B
ChildNode directly below anotherB is child of A
Leaf (Terminal)Node with no children (Degree = 0)Bottom-most nodes
Internal NodeAny node that is NOT a leafHas at least 1 child
SiblingsNodes sharing the same parentB and C if both children of A
Degree of NodeNumber of childrenLeaf = 0, Binary node = 0/1/2
Degree of TreeMaximum degree among all nodesBinary tree = 2
LevelRoot = Level 0, children = Level 1, etc.Distance from root
HeightLongest path from node to any leafRoot height = tree height
DepthPath length from Root to the nodeRoot depth = 0
PathSequence of nodes from one to anotherA → B → D
SubtreeAny node and all its descendantsRooted at any non-root node

Binary Trees: The Core Structure

Rule: Every node can have at most 2 children — the Left Child and the Right Child.

Binary Tree Types — Comparison

TypeDefinitionPropertiesUse Case
Full (Strict)Every node has 0 or 2 childrenNo node with exactly 1 childExpression trees
CompleteAll levels filled except possibly last; last level filled left-to-rightArray representation efficientHeaps
PerfectAll internal nodes have 2 children; all leaves at same levelMost symmetric binary treeTheoretical analysis
Degenerate (Skewed)Every node has only 1 childEssentially a linked listWorst-case BST
BalancedHeight difference between left/right ≤ 1 for every nodeO(log n) operations guaranteedAVL, Red-Black trees

Binary Tree Mathematical Properties

PropertyFormulaExample (height h = 3)
Max nodes at level L2^LLevel 3: 2³ = 8 nodes
Max total nodes (height h)2^(h+1) - 12⁴ - 1 = 15 nodes
Min height for n nodes⌊log₂(n)⌋15 nodes: ⌊log₂(15)⌋ = 3
Leaf nodes in Full BT(n + 1) / 215 nodes: 8 leaves
Internal nodes in Full BT(n - 1) / 215 nodes: 7 internal
Edgesn - 115 nodes: 14 edges

Worked Example: Identify Tree Properties

           A          Level 0
         /   \
        B     C        Level 1
       / \     \
      D   E     F      Level 2
         / \
        G   H          Level 3
PropertyValue
RootA
LeavesD, G, H, F
Internal NodesA, B, C, E
Height3
Degree of Tree2 (Binary)
Siblings of ED
Depth of E2
Height of B2
Total Nodes8
Total Edges7
Is it Full?No (C has only 1 child)
Is it Complete?No (Level 2 not filled left-to-right)