அல்கோரிதம்trees vocabulary

மர அமைப்பு — சொற்களும் வேர் மரமும்

TT
Testlaa Team
May 14, 20261 min read

Tree — cycles இல்லை; root — parent/child direction. trees — forest/subtree.

Try this in Python

from __future__ import annotations
from dataclasses import dataclass


@dataclass
class TreeNode:
    val: int
    left: TreeNode | None = None
    right: TreeNode | None = None

# Tiny example: root with two children
root = TreeNode(1, TreeNode(2), TreeNode(3))
print(root.val, root.left.val if root.left else None)

Key takeaways

  • Root-லிருந்து directed edges.
  • Height vs depth.
  • Subtree — recursion.

Tags:

Tree structuresPythonமாணவர்கள்