📢 CDAC C-CAT Feb 2027 — Dates Announced | 25 Nov 2026 to 29 Dec 2026 Form Filling View Details →
← All Free Notes

Data Structures and Algorithms

Section B: C, C++, DSA, OS, Networking & AI

Introduction to Data Structures; Arrays — Static Data Structure

Introduction to Data Structures; Arrays — Static Data Structure

Introduction to Data Structures

What is a Data Structure?

A data structure is a way of organizing, storing and managing data in a computer so

that it can be accessed and modified efficiently.

Formal Definition: A data structure is a collection of:

  • Data — the values stored

-

Relationships — how the data is related

  • Operations — what can be done with the

data

Why Data Structures?

  • Efficiency — operations run faster with right data structure
  • Memory usage —

optimal use of available memory

  • Code clarity — well-chosen structures make code easier

to understand

  • Problem solving — many problems have natural DS solutions

Classification of Data Structures

```

DATA STRUCTURES

├── Primitive (Basic)

│ ├── Integer

│ ├── Float

│ ├── Character

│ └── Boolean

└── Non-Primitive (Abstract)

├── Linear (elements arranged in sequence)

│ ├── Static: Arrays

│ └── Dynamic: Linked List, Stack, Queue

└── Non-Linear (hierarchical / network)

├── Trees (hierarchical)

└── Graphs (network/mesh)

```

Linear vs Non-Linear

Abstract Data Type (ADT)

An ADT defines:

  • What the data structure does (operations and behavior)
  • **NOT

how** it is implemented (implementation-independent)

Example — Stack ADT:

  • Operations: push, pop, peek, isEmpty, isFull
  • Implementation:

can be array-based or linked-list-based

Arrays — Static Data Structure

What is an Array?

An array is a collection of elements of the same data type stored in **contiguous

memory locations**.

```c

int arr[5] = {10, 20, 30, 40, 50};

Index: [0] [1] [2] [3] [4]

Value: 10 20 30 40 50

Address: 100 104 108 112 116 (int = 4 bytes)

```

Properties of Arrays

Array Operations

Array in C

```c

#include

int main() {

int arr[5] = {56, 4, 43, 33, 2};

// Access element

printf("Element at index 2: %d\n", arr[2]); // 43

// Traverse

for (int i = 0; i < 5; i++) {

printf("arr[%d] = %d\n", i,

arr[i]);

}

// Find minimum

int min = arr[0];

for (int i = 1; i < 5; i++) {

if

(arr[i] < min) min = arr[i];

}

printf("Minimum: %d\n", min); // 2

return 0;

}

```

2D Arrays (Matrix)

```c

int matrix[3][4]; // 3 rows, 4 columns

// Access element at row 1, column 2

matrix[1][2] = 42;

// Traverse 2D array

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 4; j++) {

printf("%d ", matrix[i][j]);

}

printf("\n");

}

```

Memory layout (row-major order):

```

matrix[0][0] matrix[0][1] matrix[0][2] matrix[0][3]

matrix[1][0] matrix[1][1] matrix[1][2] matrix[1][3]

matrix[2][0] matrix[2][1] matrix[2][2] matrix[2][3]

All stored continuously in memory

```

Advantages and Disadvantages of Arrays

Continue full topic on App →

Practice MCQs (20)

1. Which data structure does not support a traverse operation?

  • A. Linked list
  • B. Queue
  • C. Array
  • D. Stack

2. Which data structure is used for implementing DFS in a graph?

  • A. Stack (or recursion)
  • B. Linked list
  • C. Queue
  • D. Heap

3. A structure that contains at least one member pointing to the same structure type is called:

  • A. Recursive structure
  • B. Inner structure
  • C. Self-referential structure
  • D. Nested structure

4. Which of the following is true about arrays vs linked lists?

  • A. Lists have O(1) random access, arrays don't
  • B. Lists support no dynamic insertion
  • C. Arrays and lists behave the same
  • D. Arrays have O(1) random access, lists don't

5. Binary search requires the data to be:

  • A. Random
  • B. Sorted
  • C. Dense
  • D. Hashed

6. Which of these is a linear data structure?

  • A. Graph
  • B. Tree
  • C. Heap
  • D. Queue

7. Which data structure is used for implementing BFS in a graph?

  • A. Array
  • B. Stack
  • C. Queue
  • D. Heap

8. Which data structure is used to implement a priority queue efficiently?

  • A. Stack
  • B. Linked list
  • C. Binary heap
  • D. Array

9. Best data structure to implement an LRU cache with O(1) operations:

  • A. Hash map + doubly linked list
  • B. BST
  • C. Single linked list
  • D. Array

10. Which data structure is best for implementing a graph of millions of nodes and few edges per node?

  • A. Tree
  • B. Adjacency list
  • C. Adjacency matrix
  • D. Edge list only

11. Which of these is an example of a non-linear data structure?

  • A. Queue
  • B. Array
  • C. Stack
  • D. Tree

12. Which of these is the best data structure to check balanced parentheses?

  • A. Heap
  • B. Stack
  • C. Queue
  • D. Linked List

13. When pushing to a full (static) stack occurs, it is called:

  • A. Overflow
  • B. Segmentation
  • C. Collision
  • D. Underflow

14. In a binary heap, children of node at index i (0-based array) are at:

  • A. 2i+1, 2i+2
  • B. i-1, i+1
  • C. 2i, 2i+1
  • D. i/2

15. Which graph data structure consumes O(V²) memory?

  • A. Adjacency list
  • B. Incidence list
  • C. Adjacency matrix
  • D. Edge list

16. Which traversal is NOT possible using a normal (non-threaded) BST without recursion/auxiliary structure?

  • A. Traversal using only O(1) extra space
  • B. All require O(log n) space
  • C. Level-order using stack
  • D. Iterative traversals using stack

17. Which data structure is used for undo operations in editors?

  • A. Graph
  • B. Stack
  • C. Queue
  • D. Heap

18. What is the time complexity of deleting an element from an unsorted array of n elements (preserving order not required)?

  • A. O(log n)
  • B. O(n)
  • C. O(1)
  • D. O(n²)

19. Which of these is an advanced (non-linear) DS?

  • A. Array
  • B. Stack
  • C. Queue
  • D. Tree

20. Which of these data structures is suitable for implementing an event-driven simulation (events ordered by time)?

  • A. BST
  • B. Priority Queue (min-heap on time)
  • C. Stack
  • D. Queue
View App Pricing →