#### Data Structure using C by Himanshu Gulati

# Note for Data Structure using C - DS by HIMANSHU GULATI

#### Suggested Materials

#### Recommended Subjects

##### Basic Electrical Engineering

##### Mechanics

##### Applied Mathematics - 2

##### Business Communication

##### Applied Chemistry

##### Text from page-1

TREE DATA STRUCTURES GENERAL DEFINITION : In computer science, a tree is a widely used abstract data type (ADT) that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes. RECURSIVE DEFINITION : A tree data structure can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a list of references to nodes (the "children"), with the constraints that no reference is duplicated, and none points to the root. TERMINOLOGY USED IN TREES Root: The top node in a tree. Child: A node directly connected to another node when moving away from the Root. Parent: The converse notion of a child. Siblings: A group of nodes with the same parent. Descendant: A node reachable by repeated proceeding from parent to child. Ancestor: A node reachable by repeated proceeding from child to parent. Leaf (or External node): A node with no children. Branch (Internal node): A node with at least one child. Degree: The number of sub trees of a node. Edge: The connection between one node and another. Path: A sequence of nodes and edges connecting a node with a descendant. Level: The level of a node is defined by 1 + (the number of connections between the node and the root). Height of node: The height of a node is the number of edges on the longest path between that node and a leaf. Height of tree: The height of a tree is the height of its root node. Depth: The depth of a node is the number of edges from the tree's root node to the node. Forest: A forest is a set of n ≥ 0 disjoint trees. Common Operations • • • • • • • • Enumerating all the items Enumerating a section of a tree Searching for an item Adding a new item at a certain position on the tree Deleting an item Pruning: Removing a whole section of a tree Grafting: Adding a whole section to a tree Finding the root for any node Common Uses • • • • • Representing hierarchical data Storing data in a way that makes it efficiently searchable Representing sorted lists of data As a workflow for compositing digital images for visual effects Routing algorithms

## Leave your Comments