Tree is a fundamental data structures. It is non linear in nature. It is defined as a collection of elements(known as nodes) in which one element is special ( called as root) which represent the first element of this collection.
Applications of tree
- To represent hierarchical relations among elements
- For efficient searching through binary search tree (BST)
- For efficient sorting using heap (heapsort – complexity nlogn )
- For make efficient operations ( insert, delete, search) through self balanced tree (such as AVL tree, Red Black tree etc.)
- For implementing indexing in databases (B-tree, B+tree etc.)
- For finding shortest path trees to multiple destinations (e.g., minimum spanning tree)
Lets develop good understanding of the basic of TREE. [Click the following links to watch the video]
- Introduction to TREE Data Structures
- Binary Trees and It Representation in Memory
- Traversing a Binary Tree – PREORDER, POSTORDER & INORDER TRAVERSAL
- Constructing Binary Tree using Given Traversing Sequences
- Traversing A Binary Tree – Preorder, Postorder & Inorder Traversal
- Expression Trees
- Binary Search Trees (BST)
- AVL Trees
- Threaded Binary Tree
- M-way Tree / B-Tree / B+ trees
You are invited to raise queries by writing your question in the box given below
Important Terms Used with Tree data Structure
- Root − The first node of the tree is called root.
- Parent − First ancestor of any node is called called parent (Note- Root has no parent)
- Child − First descendant of any node is called child (Note – Leaf node has no child)
- Leaf − The node which is terminal node (i.e. it has no child)
- Subtree − It represents the descendants of a node.
- Path − It refers to the sequence of connected nodes in a tree.
- Traversing − It means visiting nodes of a tree in a specific order.
- Levels − It represents the generation of a node (i.e root node is at level 0, then next child node is at level 1 and so on.
- keys − It represents a value stored in a node.
Good morning I have two question about tree is it possible that one parent has more than 3 or 4 child nodes are there any limit for using child nodes?
Second as I watch video lecture, height of tree is maximum depths of any nodes(3) which is depths of nodes does not greater than 3 ? For example: Can I write like A is root and B, C , D, J, K and so on descendant are there any limit of descendant?
Thank you for answering
In a tree, anode can have as many childs. WIth specific tree, there is a limitation on maximum number of child.
For example, Binary (two-way) tree can have max. 2 childs, 3-way can have maximum 3 childs. In general M-way can have maximum m-childs.
Second question is not very clear. But the statement height of tree is maximum depths of any nodes is correct.
Good evening professor, I would like to ask a question about Balancing Factor in AVL tree.
By watching your video lecture, BF=(Height of Right subtree) – (Height of Left subtree), but in other recourses like https://www.javatpoint.com/avl-tree shows that BF=(Height of Left subtree) – (Height of Right subtree)
Which one is correct?
Thank you in advance.
Dear Abdullo
In practical, it does not differ whether you take R-L or L-R for finding Balancing Factor (-1 0r 1) both are balanced.
Moreover, you need to stick to one particular notation for your operations.
In my video lecture, I demonstrated
1. All Insertion operations using R-L
2. All Deletion Operations using L-R
To make it simple, you always apply L-R for all operations (i.e. insertions & deletions)
Hope, your confusion is resolved.
Best Wishes