Docsity

Trees and different types of binary trees, Cheat Sheet of Data Structures and Algorithms

Partial preview of the text

Download Trees and different types of binary trees and more Cheat Sheet Data Structures and Algorithms in PDF only on Docsity!

TREE

DATA STRUCTURE

PRESENTED BY

D. ROHITH RAJ

CSE- 1ST YEAR

TREE DATA STRUCTURE: ⏩ A tree is a non-linear data structure used to store data in a hierarchical structure. It consists of nodes connected by edges.

TYPES OF TREES:

1. GENERAL TREE:

⏩ A node can have any number of children. ⏩ No restriction on branches.

2. BINARY TREE:

⏩ A binary tree is a special type of tree where each node has at most two children. ⏩These two children are called: ➡ Left child ➡Right child

4. FULL BINARY TREE:

⏩A full binary tree is a binary tree in which every node has either 0 or 2 children. ⏩No node has only one child. ⏩Nodes are either leaf nodes (0 children) or internal nodes (2 children).

*⃣ KEY POINTS:

➡No empty spaces are allowed between nodes in the last level. ➡Efficient for array (sequential) representation. ➡Used in heap data structures.

6. PERFECT BINARY TREE:

⏩A perfect binary tree is a binary tree in which: ⏩All internal nodes have exactly 2 children, and ⏩All leaf nodes are at the same level (same depth).

➡A skewed tree is also called a degenerate tree. *⃣ TYPES OF SKEWED BINARY TREE: ➡ 1. LEFT SKEWED TREE: All nodes have only left child. ➡ 2. RIGHT SKEWED TREE: All nodes have only right child.

*⃣ KEY POINTS:

➡Each node has only one child. ➡Height of the tree = number of nodes. ➡Searching becomes slow (like linear search)

✅ ADVANTAGES:

✅ Represents hierarchical relationships. ✅ Efficient searching and sorting. ✅ Flexible structure.

❌ DISADVANTAGES:

❌ Complex implementation ❌ Requires extra memory

THANK YOU