# What Is Parent Node in Data Structure?

//

Larry Thompson

What Is Parent Node in Data Structure?

In data structures, a parent node is a concept that refers to a particular element in a hierarchical structure that has one or more children nodes connected to it. This concept is commonly used in various data structures such as trees, graphs, and linked lists.

## Understanding the Hierarchical Structure

In a hierarchical structure, elements are organized in a top-down manner, forming a tree-like structure. Each element within this structure is called a node. The parent node is the one that is positioned higher in the hierarchy and can have one or more child nodes directly connected to it.

Let’s take an example of a family tree to understand this concept better:

• Parent Node: John Doe
• Child Nodes:
• Mary Doe
• Lisa Doe

In this example, John Doe is the parent node as he holds a higher position in the family tree hierarchy. Mary Doe, Adam Doe, and Lisa Doe are his child nodes as they are directly connected to him.

## Application in Trees and Graphs

The concept of parent nodes becomes even more crucial when dealing with tree and graph data structures.

### Trees:

In tree structures, each node can have zero or more child nodes. The topmost node in the hierarchy is called the root node.

All other nodes have exactly one parent except for the root node which does not have any. Nodes that do not have any children are known as leaf nodes.

To visualize this, let’s consider an example of an organization chart:

• Root Node: CEO
• Parent Nodes:
• CTO
• Software Development Manager
• Developer 1
• Developer 2
• CFO
• Finance Manager
• Accountant 1In this example, the CEO is the root node. The CTO and CFO are parent nodes as they have child nodes directly connected to them.

### Graphs:

In graph structures, nodes can have multiple connections with other nodes, forming a network. Each node in a graph can have zero or more parent nodes and zero or more child nodes.

To illustrate this, let’s consider a social network graph:

User A:Follower Nodes:User BUser CUser D