NEW
Font size
WorksheetsArray & Data Structure MCQs
Total questions: 26
Worksheet time: 13mins
What is the time complexity of accessing an element in an array by index?
O(n)
O(log n)
O(1)
O(n log n)
Which data structure uses contiguous memory locations?
Linked List
Stack
Queue
Array
What is the worst-case time complexity for searching an element in an unsorted array?
O(1)
O(log n)
O(n)
O(n log n)
Which operation is costliest in an array?
Access
Update
Insertion
Traversal
What happens when we insert an element at the beginning of an array?
No change
Only first element shifts
All elements shift right
Last element removed
Which of the following is NOT a linear data structure?
Array
Stack
Queue
Tree
What is the space complexity of an array of size n?
O(1)
O(n)
O(log n)
O(n2)
Which traversal technique is used in arrays?
Inorder
Preorder
Sequential
Postorder
Which data structure follows FIFO principle?
Stack
Queue
Array
Tree
What is the index of the first element in an array (most languages)?
-1
0
1
Depends on compiler
What is the time complexity of deleting an element from the middle of an array?
O(1)
O(log n)
O(n)
O(n log n)
Which sorting algorithm is best for nearly sorted arrays?
Bubble Sort
Selection Sort
Insertion Sort
Quick Sort
Which operation is NOT possible directly on an array?
Traversal
Random Access
Dynamic Resizing
Sorting
What is the maximum number of children a binary tree node can have?
1
2
3
Unlimited
Which data structure is used for recursion?
Queue
Stack
Array
Linked List
Which of the following is an advantage of arrays?
Dynamic size
Easy insertion/deletion
Fast access
Memory efficiency
Which searching technique works only on sorted arrays?
Linear Search
Binary Search
Hashing
DFS
What is the worst-case time complexity of binary search?
O(1)
O(n)
O(log n)
O(n log n)
Which data structure allows insertion and deletion at only one end?
Queue
Stack
Deque
Array
Which of the following represents a homogeneous data structure?
Structure
Class
Array
File
What will be the output of the following code? int a[] = {10, 20, 30, 40}; printf("%d", a[2]);
10
20
30
40
What is the time complexity of the following code? for(int i = 0; i < n; i++) printf("%d", a[i]);
O(1)
O(log n)
O(n)
O(n2)
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);
10
12
14
15
What will be printed? int a[] = {5, 10, 15}; printf("%d", sizeof(a)/sizeof(a[0]));
1
2
3
6
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]);
1 4
4 1
3 2
2 3
for(int i = 0; i < sizeof(a)/sizeof(int); i++) printf("%d", a[i]);
1
2
3
4
