Skip to content

Latest commit

 

History

History
96 lines (58 loc) · 4.48 KB

BinaryTree.md

File metadata and controls

96 lines (58 loc) · 4.48 KB

Binary Tree

  • A binary tree is a hierarchical data structure in which each node has at most two children, typically called the left child and right child.

Key Concepts and Terminology

  • Node: A structure that contains a value (data) and links to its children nodes.
  • Root: The topmost node in the tree.
  • Leaf Node: A node with no children (both left and right children are null).
  • Internal Node: A node with at least one child.
  • Parent and Child: A node that has links to other nodes is considered the parent of those nodes, and the linked nodes are its children.
  • Subtree: Any node along with its descendants forms a subtree.
  • Height: The longest path from a node to a leaf. The height of the tree is the height of the root node.
  • Depth: The path length from the root to a given node.

Binary Tree Traversals

  • Tree traversals are ways of visiting every node in a binary tree. Common traversal methods include:

Preorder Traversal (Root, Left, Right):

Inorder Traversal (Left, Root, Right):

Postorder Traversal (Left, Right, Root):

Level Order Traversal (Breadth-First):

Common Operation in Binary Tree

  • Insertion
  • Deletion
  • Searching
  • Height Calculation
  • Counting Nodes
  • Counting Leaf Nodes

Binary Tree Properties

  • Maximum Nodes: A binary tree with height k can have at most 2 ^ (k + 1) nodes.
  • Minimum Height: For n nodes, the minimum heights of a binary trees have no strict rules for nodes placement or balance, so they can become skewed.


Connect with me:

saurabhbahadur saurabhbahadur singhsaurabhbahadur saurabhbahadur_ mighty saur saurabhbahadur aQR27Bg7de