Loading

Linear & Nonlinear Data Structure

Linear & Nonlinear Data Structure

Linear data structure

Data structure is said to be Linear if its elements are connected in a linear fashion by means of logically or in sequence memory locations. There are two ways to represent a linear data structure in memory,

1.Static memory allocation 2. Dynamic memory allocation

Examples of Linear Data Structure are Stack and Queue.

Stack: Stack is a data structure in which insertion and deletion operations are performed at one end only. The insertion operation is referred to as PUSH and deletion operation is referred to as POP operation. Stack is also called as Last in First out (LIFO) data structure.

Queue: The data structure which permits the insertion at one end and Deletion at another end, known as Queue. The end at which deletion occurs is known as FRONT end and another end at which insertion occurs is known as REAR end.The queue is also called as First in First out (FIFO) data structure.

Nonlinear data structures:

Non-linear data structures are those data structure in which data items are not arranged in a sequence. Examples of Non-linear Data Structure are Tree and Graph.

Tree: A tree can be defined as a finite set of data items (nodes) in which data items are arranged in branches and sub-branches according to requirement. Trees represent the hierarchical relationship between various elements. Tree consists of nodes connected by an edge, the node represented by a circle, and edge lives connecting to a circle.

Graph: Graph is a collection of nodes (Information) and connecting edges (Logical relation) between nodes. A tree can be viewed as a restricted graph.

Graphs have many types: • Un-directed Graph • Directed Graph • Mixed Graph • Multi Graph • Simple Graph • Null Graph • Weighted Graph

Difference between Linear and Non-Linear Data Structure

diff.png

Related Articles

Leave a Reply

Comments