Trees

TREE 
A tree is a finite set of one or more nodes such that there is a specially designated node called the Root, and zero or more non empty sub trees T1, T2....Tk, each of whose roots are connected by a directed edge from Root R.

The ADT tree

A tree is a finite set of elements or nodes. If the set is non-empty, one of the nodes is distinguished as the root node, while the remaining (possibly empty) set of nodes are grouped into subsets, each of which is itself a tree. This hierarchical relationship is described by referring to each such subtree as a child of the root, while the root is referred to as the parent of each subtree. If a tree consists of a single node, that node is called a leaf node.

It is a notational convenience to allow an empty tree. It is usual to represent a tree using a picture.

ROOT : A node which doesn't have a parent. In the above tree.
NODE : Item of Information.
LEAF : A node which doesn't have children is called leaf or Terminal node.
SIBLINGS : Children of the same parents are said to be siblings,. F, G are siblings. PATH : A path from node n, to nk is defined as a sequence of nodes n1, n2,n3....nk such that ni is the parent of ni+1. for . There is exactly only one path from each node to root.
LENGTH : The length is defined as the number of edges on the path.
DEGREE : The number of subtrees of a node is called its degree.

BINARY TREE

Definition :-
Binary Tree is a tree in which no node can have more than two children.
Maximum number of nodes at level i of a binary tree is 2i-1.
A binary tree is a tree which is either empty, or one in which every node: has no children; or has just a left child; or has just a right child; or has both a left and a right child

Trees Trees Reviewed by Unknown on 04:34 Rating: 5

No comments:

Powered by Blogger.