Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1: Fundamentals of Data Structures

Lesson 1 of 14 in the free Data Structure notes on Siksha Sarovar, written by Rohit Jangra.

Introduction to Data Structures

The study of Data Structures is fundamental to Computer Science. It is not just about storing data; it's about structuring data in a way that models the real-world problem effectively and allows for efficient processing. A data structure scheme involves the logical arrangement of data and the set of operations that can be performed on it.

What is an Abstract Data Type (ADT)?

Definition: An ADT is a mathematical model for data types where it specifies the type of data, the operations that can be performed, and the behavior of those operations — without specifying how they are implemented.

ComponentDescriptionExample (Stack ADT)
DataWhat values it storesA collection of elements
OperationsWhat can be donePush, Pop, Peek, isEmpty
BehaviorRules/constraintsLIFO ordering, Overflow/Underflow checks
ImplementationNOT specified by ADTCould use Array or Linked List internally
Key Insight: The same ADT can have multiple implementations. A Stack ADT can be implemented using an array OR a linked list. The user of the Stack doesn't need to know which.

Basic Terminology and Definitions

To understand data structures, we must first define the building blocks of data organization.

TermDefinitionExample
DataRaw, unprocessed facts, figures, or values25, "John", 75.5
InformationProcessed data that holds meaning"John is 25 years old"
Data ItemSmallest unit of information with meaningRoll Number in a Student record
Group ItemData item divisible into sub-itemsDate of Birth → Day, Month, Year
Elementary ItemData item that cannot be divided furtherGender (M/F), ID Number
EntityReal-world object or conceptStudent, Employee, Car
AttributeProperty describing an entityColor, Height, Salary
Entity SetCollection of similar entitiesAll students in a class

Field, Record, and File — The Data Hierarchy

Bit → Byte → Field → Record → File → Database
  • Field: A single elementary unit (e.g., phone number cell).
  • Record: Collection of related fields (e.g., one student row).
  • File: Collection of related records (e.g., entire student table).

Classification of Data Structures

1. Primitive vs. Non-Primitive

FeaturePrimitiveNon-Primitive
DefinitionFundamental types from the languageComplex structures derived from primitives
Examplesint, float, char, booleanArrays, Lists, Stacks, Queues, Trees
SizeFixed by languageCan grow/shrink
OperationsArithmetic, LogicalTraversal, Insertion, Deletion, Sorting

2. Linear vs. Non-Linear

FeatureLinearNon-Linear
ArrangementSequential, one after anotherHierarchical or networked
Predecessor/SuccessorEach element has exactly one (except first/last)Multiple predecessors/successors possible
MemorySequential or linkedLinked via multiple pointers
TraversalSingle passMultiple paths
ExamplesArray, Stack, Queue, Linked ListTree, Graph
Use CaseOrdered data, sequencesHierarchies, networks, relationships

3. Static vs. Dynamic

FeatureStaticDynamic
Memory AllocationCompile-timeRun-time
SizeFixed — cannot changeCan grow/shrink
SpeedFaster (direct indexing)Slower (pointer traversal)
Memory EfficiencyWasteful if over-allocatedEfficient — allocates as needed
ExampleArrayLinked List

Operations on Data Structures

OperationDescriptionTime Complexity (varies by DS)
TraversingVisiting every element exactly onceO(n)
SearchingFinding a specific elementO(n) linear, O(log n) binary
InsertingAdding a new elementO(1) to O(n)
DeletingRemoving an existing elementO(1) to O(n)
SortingArranging in orderO(n log n) efficient sorts
MergingCombining two sorted structuresO(n + m)

Choosing the Right Data Structure

ScenarioBest DSWhy
Fast access by indexArrayO(1) random access
Frequent insertions/deletionsLinked ListO(1) insert at known position
LIFO ordering (undo, recursion)StackPush/Pop at one end
FIFO ordering (scheduling, BFS)QueueEnqueue rear, Dequeue front
Hierarchical data (file system)TreeParent-child relationships
Relationships/connections (maps)GraphMany-to-many connections
Fast search + insert + deleteBST / Hash TableO(log n) or O(1) average