Tree & Binary Tree
1. Binary Tree
A binary tree is a tree data structure in which each node has at most two children, which
are referred to as the left child and the right child.
Types of Binary Tree
•Perfect binary tree is a
binary tree in which every level are at the same depth.
•Complete binary tree is a
binary tree in which every level, except possibly the last, is completely
filled, and all nodes are as far left as possible. A perfect binary tree is a
complete binary tree.
•Skewed binary tree is a
binary tree in which each node has at most one child.
•Balanced binary tree is a
binary tree in which no leaf is much farther away from the root than any
other
leaf (different balancing scheme allows different definitions of “much
farther”).
Perfect Binary Tree
Complete Binary Tree
Skewed Binary Tree
2. Difference Between Tree & Graph
Tree :
1. A tree is a special kind of graph that there are never multiple paths exist. There is always one way to get from A to B.
2. Tree must be connected.
3. Since it connected we can reach from one particular node to all other nodes. This kind of searching is called traversal. 4. Tree contains no loops, no circuits.
|
Tidak ada komentar:
Posting Komentar