Tree Data Structure: Concepts, Types, and Algorithms

marceldavidbaroi 12 views 17 slides Mar 16, 2025
Slide 1
Slide 1 of 17
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17

About This Presentation

This presentation provides an in-depth understanding of Tree Data Structures in computer science. It covers the fundamental concepts, different types of trees (Binary Tree, BST, AVL, B-Trees, etc.), and essential algorithms like traversal, insertion, and deletion. Learn how trees are used in data or...


Slide Content

T ree Presented by: Shatabdi Shil Piu ID: 201-15-3421 Section: PC I

Basic A B C D E Node: A node is an entity that contains a key or value and pointers to its child nodes.

A B C D E Edge: It is the link between any two nodes.

A B C D E Root It is the topmost node of a tree. root

A B C D E Height of a Node The height of a node is the number of edges from the node to the deepest leaf Depth of a Node The depth of a node is the number of edges from the root to the node. Height 2 Height 1 Height 0 Depth 0 Depth 1 Depth 2

A B C D E Parent : Any node except the root node has one edge upward to a node called parent. Child : The node below a given node connected by its edge downward is called its child node. Child Node Parent Node siblings

Tree Traversals Depth First Traversals Inorder Traversal Preorde Traversal Postorder Traversal Breadth First or Level Order Traversal

1 2 3 4 5 1.Inorder First, visit all the nodes in the left sub-tree Then the root node Visit all the nodes in the right sub-tree l eft-> root-> right

1 2 3 4 5 InorderTraversals 4-> 2 -> 5 -> 1 -> 3 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 2.Preorder Visit root node Visit all the nodes in the left subtree Visit all the nodes in the right subtree r oot-> left-> right

1 2 3 4 5 Preorder Traversals 1-> 2 -> 4 -> 5 -> 3 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 3.Postorder Visit all the nodes in the left subtree Visit all the nodes in the right subtree Visit the root node left-> right->root

1 2 3 4 5 Postorder Traversals 4 -> 5 -> 2 -> 3 -> 1 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

1 2 3 4 5 Tree Traversals Breadth First or Level Order Traversal

1 2 3 4 5 Breadth First or Level Order Traversal 1 ->2 -> 3 -> 4 -> 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

Thaharim Khan Lecturer Department of Computer Science and Engineering Daffodil International University

Thank You