3.4.1 · HinglishTrees

Tree terminology — root, leaf, height, depth, degree, subtree

1,822 words8 min readRead in English

3.4.1 · Coding › Trees


Tree KYA hai (foundation)

edges KYU? Root ko chhodkar har node apne parent se exactly ek edge se connected hota hai. Ye nodes hain, har ek ek edge contribute karta hai → edges. Root kuch contribute nahi karta (uska koi parent nahi hota). Ye derived hai, memorize nahi karna.


Core vocabulary

Figure — Tree terminology — root, leaf, height, depth, degree, subtree

Depth vs Height — wo part jahan sabka confusion hota hai


Worked examples


Common mistakes (Steel-manned)


Recall Ek 12-saal ke bachhe ko explain karo (hidden)

Socho ek family tree ulta draw kiya gaya hai. Bilkul upar great-grandparent hai, woh root hai. Jinka koi bachha nahi hai woh leaves hain. Tumhari depth hai kitne steps upar chalna padega top boss tak pahunchne ke liye. Tumhari height hai tumhari branch mein sabse door ke bachhe tak kitne steps neeche jaana padega. Degree bas hai tumhare kitne direct children hain. Subtree hai "tum aur tumhare neeche poori family line" — yeh apne aap mein ek chhota tree hai. Koi apna khud ka ancestor nahi ho sakta, isliye koi loops nahi hote!


Active-recall flashcards

nodes wale tree mein kitne edges hote hain, aur KYU?
; root ko chhodkar har node apne parent ko exactly ek edge contribute karta hai.
Leaf ki definition?
A node with no children.
Root ki definition?
Woh akela node jiska koi parent nahi hota; sabse upar wala node.
Root ki depth kya hoti hai?
0 (root se apne tak zero edges).
Leaf ki height kya hoti hai?
0 (usse neeche leaf tak zero edges — khud hi leaf hai).
Depth vs height, ek ek line mein?
Depth = root tak upar edges; Height = sabse gehari leaf tak neeche edges.
Node v ki height ka recursive formula?
, leaf height ke saath.
Node ki degree vs tree ki degree?
Node degree = uske children ki sankhya; tree degree = sabhi nodes mein max degree.
Subtree kya hota hai?
A node together with all its descendants, viewed as a tree on its own.
Kya leaf bottom level se upar appear ho sakta hai?
Haan — leaf matlab "koi children nahi", jo kisi bhi depth par ho sakta hai.
Height aur degree () wale tree mein max nodes?
, ka sum.
Poore tree ki height barabar hoti hai?
Height of the root = max depth among all nodes.

Connections

  • Binary Trees — special case jahan tree ki degree ho.
  • Binary Search Trees — is terminology par based ordering invariant.
  • Tree Traversals — DFS/BFS nodes ko depth/level ke hisaab se visit karte hain.
  • Balanced Trees (AVL, Red-Black)height control karte hain taaki operations rahein.
  • Recursion — height/subtree definitions inherently recursive hain.
  • Graphs — tree ek connected acyclic graph hai; degree definitions compare karo.

Concept Map

has one

n nodes gives

no cycles

top of

node with no children

node with children

count of children

path down to node

path up defines

recursive

plus descendants

of root equals

Tree

Root no parent

n-1 edges

Acyclic structure

Parent child links

Leaf

Internal node

Degree of node

Depth root is 0

Height leaf is 0

1 plus max child height

Subtree

Tree height