# Introduction to Tree Data Structure

In computer science, a tree is an abstract model of a hierarchical structure. A tree consists of nodes with a parent-child relation. Previous data structures placed data in linear order. Some data organizations require categorizing data into groups, subgroups. Trees are a hierarchical data structure of nodes. Nodes are linked by edges. A parent node references one or more nodes (children nodes) that are “lower” in the tree hierarchy.

If node u has address of node v, then v is the child of u

### Root Node

Node without parent is called root node. Except for the root (no parent), every node has exactly one parent (by definition). A tree has only one **root node.**

### Sibling Node

**sibling**.

### Internal Nodes

**internal**if it has one or more children.

### Leaf Node

**leaf**if it has no children

### Ancestor and Descendant Nodes

**ancestor**of a node is either the node’s parent or any ancestor of the node’s parent i.e. parent, grandparent, grand-grandparent. The root is an ancestor of every other node.

**Descendant**of a node: child, grandchild, grand-grandchild.

### Subtree

**subtree**of T rooted at node v is the tree consisting of all the descendents of v in T (including v)

### Depth of a Tree

### Height of a Tree

The path from the root, A, to the leaf, I, is denoted as AFI and has a length of 2. ABD is the path from the root, A, to the leaf, D, and also has a length of 2.

### Types of Trees

**1. General tree**– a node can have any number of children

**2. Binary tree**– a node can have at most two children

### Related Posts

- Binary Search Trees and Data Structure
- Heap data structure in C++
- Binary Trees and Binary Search Trees
- Binary Expression Trees
- Graph search in C++
- Heap Sort with Graphical Explanation
- Introduction to Graph data structure
- Queue Implementation in C++
- Operations on Binary Search Trees (BST)
- Doubly Linked Lists
- Circular Linked Lists
- Advanced Data Structures Tutorial using C++

### Popular Posts (last 30 days)

- Applications of Stack in … 1134 view(s)
- Circular Linked Lists 1074 view(s)
- Attendance Management Sys… 937 view(s)
- Simple Currency Converter… 661 view(s)
- Implementing Stack Data S… 623 view(s)
- Finding Minimum, Maximum … 613 view(s)
- Recursive Factorial funct… 588 view(s)
- Graph Implementation in C… 568 view(s)
- Finding Maximum Number in… 382 view(s)
- GRASP Design Patterns 356 view(s)

### Related Links

### Tags

Android C-Sharp C/C++ language Classes Data structures Design Pattern Eclipse Game Development Graphics Design Books HTML iPhone JAVA JAVA GUI MIPS Assembly Mobile Programming Books Object Oriented PDF PHP Programming Programming Books Programming Languages Books Python RaphaelJS REST Source Code Threads Tutorial Web Development Books