PadhaikoAll subjects

Past exam question: 2078 Poush (Back), Q1(a)

Data Structure and Algorithms · 5 marks

Open in the Padhaiko app

Topic: Introduction

Question

Define Data Structure. Write down the difference between linear and non-linear data structure.

Solution

Definition of Data Structure: A data structure is a logical and mathematical model for organizing, storing, and manipulating data in computer memory so that operations (insertion, deletion, traversal, searching) can be executed efficiently in both time and space.

Linear vs. Non-Linear Data Structures:

AspectLinear Data StructureNon-Linear Data Structure
ArrangementElements are arranged sequentially one after anotherElements form hierarchical or network relationships
AdjacencyEach element has at most one predecessor and one successorOne element can connect to multiple elements (one-to-many / many-to-many)
TraversalCan be traversed completely in a single linear passRequires recursive or multi-path traversal (DFS, BFS, tree traversals)
Memory & ImplementationGenerally simpler to implement (arrays or linked lists)More complex pointer/matrix representations
ExamplesArray, Stack, Queue, Linked ListTree, Binary Search Tree, AVL Tree, Graph
Answer:

A data structure organizes data in memory for efficient access and modification. Linear structures (arrays, stacks, queues, linked lists) store items in a single sequential order, whereas non-linear structures (trees, graphs) organize items hierarchically or in arbitrary networks with multi-level connections.

All past exam questions for Data Structure and Algorithms