Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

Linear vs. non-linear data structure

Hafiza Farwa Mahmood

Overview

The data structure is a way of classifying data so that it can be stored and used efficiently. Data structure comes in two basic types. One is a linear data structure, and the second is a non-linear data structure.

%0 node_1 Data Structure node_2 Linear Data Structure node_1->node_2 node_3 Non Linear Data Structure node_1->node_3 node_1656504613062 Link List node_2->node_1656504613062 node_1656504589847 Stack node_2->node_1656504589847 node_1656504628275 Array node_2->node_1656504628275 node_1656504643515 Graphs node_3->node_1656504643515 node_1656504658877 Trees node_3->node_1656504658877
Types of data structure

Linear data structure

In the linear data structure, data elements are organized subsequently. Each element is linked with its previous and next elements. The user can traverse all elements in a single run, as elements exist at a single level.

Non-linear data structure

In the non-linear data structure, data elements are stored in a non-contiguous manner. Hierarchy is achieved somehow as data elements are arranged on multiple levels.

Comparison

Attributes

Linear data structure

Non-linear data structure


Arrangement

Sequential

Non sequential

Types

Arrays, Linked list, Stack, Queue

Trees and graphs

Levels

Single Level

Mutiple Levels

Implementation

Easy

Difficult

Efficiency

Not good enough for complex programs

Works well with high complexity programs

Applications

Undo redo, Job scheduling, Media players

AI, Robotics, Neural Networks

Traversal

Single run

Multiple runs

Memory Utilization

Inefficient

Efficient

Time Complexity

Increases as input size increase

Remains same

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring