Non-Linear Data Structures & Its Types
Q#1: Explain non-linear data structure and its types.
Ans: The elements of a non-linear data structure are not connected in a sequence. Each element can have multiple paths to connect to other elements. Examples of non-linear data structures are Tree, Graph, etc.
i. Tree:
This non-linear data structure is used to represent data containing a hierarchical relationship between elements. Tree represents its elements as the nodes connected to each other by edges. In each tree collection we have one root node, which is the very first node in out tree. If a node is connected to another node element, it is called a parent node and the connected node is called its child node.
ii. Graph:
A graph is a non-linear data structure consisting of data elements (finite set) called nodes/vertices and edges that are lines that connect any two nodes in that graph, there is no node called root or child. Graphs are used to solve network problem. There are two types of graphs.
1. Undirected Graph: In an undirected graph, nodes are connected by edges that are all bidirectional.
2. Directed Graph: In a directed graph, nodes are connected by directed edges, they only go in one direction.
Comments
Post a Comment