Page 1
Wink Notes
B.Tech CSE — 3rd Semester
Data Structures and Algorithms
— Unit - 1 —
1. Introduction to Data Structures
A data structure is a specialised format for organising, processing, retrieving, and storing data. It is a logical or mathematical model of a particular organisation of data. The choice of data structure depends on the problem to be solved and the operations to be performed.
1.1 Classification of Data Structures
Data structures are broadly classified into two categories: Primitive and Non-Primitive.
- Primitive Data Structures: These are basic structures directly operated upon by machine instructions. Examples: `int`, `float`, `char`, `pointer`.
- Non-Primitive Data Structures: Derived from primitive structures, they focus on grouping homogeneous or heterogeneous data items. Further divided into Linear and Non-Linear.
1.2 Linear vs Non-Linear Data Structures
Linear Data Structures
- Elements are arranged in a sequential or linear order.
- Every element has a unique predecessor and successor (except the first and last).
- Examples: Arrays, Linked Lists, Stacks, Queues.
- Memory allocation is usually contiguous (except Linked Lists).
- Traversal is simple, usually single-level.
Non-Linear Data Structures
- Elements are arranged in a hierarchical or interconnected manner.
- An element can be connected to multiple other elements.
- Examples: Trees, Graphs, Tries.
- Memory allocation is usually dynamic and non-contiguous.
- Traversal is complex (e.g., DFS, BFS).