wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Array & Data Structure MCQs

Total questions: 26

Worksheet time: 13mins

Name
Class
Date
1.

What is the time complexity of accessing an element in an array by index?

a)

O(n)

b)

O(log n)

c)

O(1)

d)

O(n log n)

2.

Which data structure uses contiguous memory locations?

a)

Linked List

b)

Stack

c)

Queue

d)

Array

3.

What is the worst-case time complexity for searching an element in an unsorted array?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

4.

Which operation is costliest in an array?

a)

Access

b)

Update

c)

Insertion

d)

Traversal

5.

What happens when we insert an element at the beginning of an array?

a)

No change

b)

Only first element shifts

c)

All elements shift right

d)

Last element removed

6.

Which of the following is NOT a linear data structure?

a)

Array

b)

Stack

c)

Queue

d)

Tree

7.

What is the space complexity of an array of size n?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n2)O(n^2)

8.

Which traversal technique is used in arrays?

a)

Inorder

b)

Preorder

c)

Sequential

d)

Postorder

9.

Which data structure follows FIFO principle?

a)

Stack

b)

Queue

c)

Array

d)

Tree

10.

What is the index of the first element in an array (most languages)?

a)

-1

b)

0

c)

1

d)

Depends on compiler

11.

What is the time complexity of deleting an element from the middle of an array?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

12.

Which sorting algorithm is best for nearly sorted arrays?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Quick Sort

13.

Which operation is NOT possible directly on an array?

a)

Traversal

b)

Random Access

c)

Dynamic Resizing

d)

Sorting

14.

What is the maximum number of children a binary tree node can have?

a)

1

b)

2

c)

3

d)

Unlimited

15.

Which data structure is used for recursion?

a)

Queue

b)

Stack

c)

Array

d)

Linked List

16.

Which of the following is an advantage of arrays?

a)

Dynamic size

b)

Easy insertion/deletion

c)

Fast access

d)

Memory efficiency

17.

Which searching technique works only on sorted arrays?

a)

Linear Search

b)

Binary Search

c)

Hashing

d)

DFS

18.

What is the worst-case time complexity of binary search?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

O(n log n)

19.

Which data structure allows insertion and deletion at only one end?

a)

Queue

b)

Stack

c)

Deque

d)

Array

20.

Which of the following represents a homogeneous data structure?

a)

Structure

b)

Class

c)

Array

d)

File

21.

What will be the output of the following code? int a[] = {10, 20, 30, 40}; printf("%d", a[2]);

a)

10

b)

20

c)

30

d)

40

22.

What is the time complexity of the following code? for(int i = 0; i < n; i++) printf("%d", a[i]);

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n2)O(n^2)

23.

What will be the output? int a[] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i < 5; i++) sum += a[i]; printf("%d", sum);

a)

10

b)

12

c)

14

d)

15

24.

What will be printed? int a[] = {5, 10, 15}; printf("%d", sizeof(a)/sizeof(a[0]));

a)

1

b)

2

c)

3

d)

6

25.

What is the output? int a[] = {1, 2, 3, 4}; int temp = a[0]; a[0] = a[3]; a[3] = temp; printf("%d %d", a[0], a[3]);

a)

1 4

b)

4 1

c)

3 2

d)

2 3

26.

for(int i = 0; i < sizeof(a)/sizeof(int); i++) printf("%d", a[i]);

a)

1

b)

2

c)

3

d)

4