. .
.
Search trees
.
.

 

Description

 

This experiment guides you using trees tha can handle hierarchial data structure.Trees are an important data structure in Computer Science with applications to optimization, searching, sorting,and compilers.Tree can be defined recursively as follows. A tree is a collection of nodes. An empty collection of nodes is a tree. Otherwise a tree consists of a distinguished node r, called the root, and 0 or more non-empty (sub)trees T1, T2,...., Tk each of whose roots are connected by a directed edge from r.
From the above definition, it holds that in a tree of n nodes, there will be n - 1 edges. The fact follows from the observation that each node, except the root, has one edge to its parent and every node has only one parent.
Nodes with the same parent are called as siblings.Nodes with the same parent are called as siblings.Briefly, we also mention how to implement the tree data structure. The following node declaration as a structure works.

struct node
{
int data;
node *children;
}

Notice that in any tree there is exactly one path from the root to any other node.Given a tree T, let the root node be said to be at a depth of 0. The depth of any other node ni in T is defined as the length of the path from the root to ni.Alternatively, let the depth of the root be set to 0 and the depth of a node is one more than the depth of its parent. Another notion defined for trees is the height. The height of a leaf node is set to 0. The height of a node is one plus the maximum height of its children. The height of a tree is defined as the height of the root.Alike parent-children relationship, we can also define ancestor-descendant relationship as follows. In the path from n1 to n2, n1 is an ancestor of n2 and n2 is a descendant of n1. If n1 not equal to n2, then n1 is called a proper ancestor (descendant) respectively.

 

Cite this Simulator:

.....
..... .....
Copyright @ 2017 Under the NME ICT initiative of MHRD (Licensing Terms)
 Powered by AmritaVirtual Lab Collaborative Platform [ Ver 00.11. ]