Tree Data Structure
Tree Data Structure
A tree is an abstract data type that stores elements hierarchically. With the
exception of the top element, each element in a tree has a parent element and
zero or more children elements. A tree is usually visualized by placing
elements inside ovals or rectangles, and by drawing the connections between
parents and children With straight lines.
Formally, we define a tree T as a set of nodes storing elements such that the
nodes have parent-child relationship that satisfies the following properties:
• If T is nonempty, it has a special node, called the root of T, that has no
parent.
• Each node v of T different from the root has a unique parent node w,
every node with parent w is a child of w.
Binary Tree
• Complete binary tree: is a binary tree in which every level of the tree is
completely filled except the last level. Also, in the last level, nodes should be
attached starting from the left-most position.
• Full binary tree: is a binary tree in which every node in the tree has exactly two
children. In other words, every node in the tree except the leaves has exactly two
children.
Nodes=2h+1 − 1
By:Abdul Jalil Niazai
Types of binary Tree