Olete.in
Articles
Mock Tests
🧪 Data structure MCQ Quiz Hub
Data Structure -Abstract Data Types
Choose a topic to test your knowledge and improve your Data structure skills
1. 1. Which of these best describes an array?
A data structure that shows a hierarchical behavior
Container of objects of similar types
Arrays are immutable once initialised
Array is not a data structure
2. How do you initialize an array in C?
int arr[3] = (1 2 3)
int arr(3) = {1 2 3}
int arr[3] = {1 2 3}
int arr(3) = (1 2 3)
3. How do you instantiate an array in Java?
int arr[] = new int(3)
int arr[]
int arr[] = new int[3]
int arr() = new int(3)
4. Which of the following is the correct way to declare a multidimensional array in Java?
int[] arr
int arr[[]]
int[][]arr
int[[]] arr
5. What is the output of the following Java code? public class array { public static void main(String args[]) { int []arr = {1 2 3 4 5} System.out.println(arr[2]) System.out.println(arr[4]) } }
3 and 5
5 and 3
2 and 4
4 and 2
6. What is the output of the following Java code? public class array { public static void main(String args[]) { int []arr = {1 2 3 4 5} System.out.println(arr[5]) } }
4
5
ArrayIndexOutOfBoundsException
InavlidInputException
7. When does the ArrayIndexOutOfBoundsException occur?
Compile-time
Run-time
Not an error
Not an exception at all
8. Which of the following concepts make extensive use of arrays?
Binary trees
Scheduling of processes
Caching
Spatial locality
9. What are the advantages of arrays?
Objects of mixed data types can be stored
Elements in an array cannot be sorted
Index of first element of an array is 1
Easier to store elements of same data type
10. What are the disadvantages of arrays?
Data structure like queue or stack cannot be implemented
There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size
Index value of an array can be negative
Elements are sequentially accessed
11. Assuming int is of 4bytes what is the size of int arr[15] ?
15
19
11
60
12. In general the index of the first element in an array is __________
0
-1
2
1
13. Elements in an array are accessed _____________
randomly
sequentially
exponentially
logarithmically
14. This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on Stack Operations � 1 . 1. Process of inserting an element in stack is called ____________
Create
Push
Evaluation
Pop
15. Process of removing an element from stack is called __________
Create
Push
Evaluation
Pop
16. In a stack if a user tries to remove an element from an empty stack it is called _________
Underflow
Empty collection
Overflow
Garbage Collection
17. Pushing an element into stack already having five elements and stack size of 5 then stack becomes ___________
Overflow
Crash
Underflow
User flow
18. Entries in a stack are ordered . What is the meaning of this statement?
A collection of stacks is sortable
Stack entries may be compared with the < operation
The entries are stored in a linked list
There is a Sequential entry that is one by one
19. Which of the following is not the application of stack?
A parentheses balancing program
Tracking of local variables at run time
Compiler Syntax Analyzer
Data Transfer between two asynchronous process
20. Consider the usual algorithm for determining whether a sequence of parentheses is balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?
1
2
3
4 or more
21. Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?
1
2
3
4 or more
22. What is the value of the postfix expression 6 3 2 4 + � *?
1
40
74
-18
23. Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
1
2
3
4
24. 1. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
AB+ CD*E � FG /**
AB + CD* E � F **G /
AB + CD* E � *F *G /
AB + CDE * � * F *G /
25. The data structure required to check whether an expression contains a balanced parenthesis is?
Stack
Queue
Array
Tree
26. What data structure would you mostly likely see in non recursive implementation of a recursive algorithm?
Linked List
Stack
Queue
Tree
27. The process of accessing data stored in a serial access memory is similar to manipulating data on a ________
Heap
Binary Tree
Array
Stack
28. The postfix form of A*B+C/D is?
*AB/CD+
AB*CD/+
A*BC+/D
ABCD+/*
29. Which data structure is needed to convert infix notation to postfix notation?
Branch
Tree
Queue
Stack
30. The prefix form of A-B/ (C * D ^ E) is?
-/*^ACBDE
-ABCD*^DE
-A/B*C^DE
-A/BC*^DE
31. What is the result of the following operation? Top (Push (S X))
X
X+S
S
XS
32. The prefix form of an infix expression (p + q) � (r * t) is?
+ pq � *rt
� +pqr * t
� +pq * rt
� + * pqrt
33. Which data structure is used for implementing recursion?
Queue
Stack
Array
List
34. 1. The result of evaluating the postfix expression 5 4 6 + * 4 9 3 / + * is?
600
350
650
588
35. Convert the following infix expressions into its equivalent postfix expressions. (A + B ?D)/(E � F)+G
(A B D ? + E F � / G +)
(A B D +? E F � / G +)
(A B D ? + E F/- G +)
(A B D E F + ? / � G +)
36. Convert the following Infix expression to Postfix form using a stack. x + y * z + (p * q + r) * s Follow usual precedence rule and assume that the expression is legal.
xyz*+pq*r+s*+
xyz*+pq*r+s+*
xyz+*pq*r+s*+
xyzp+**qr+s*+
37. Which of the following statement(s) about stack data structure is/are NOT correct?
Linked List are used for implementing Stacks
Top of the Stack always contain the new node
Stack is the FIFO data structure
Null link is present in the last node at the bottom of the stack
38. Consider the following operation performed on a stack of size 5. Push(1) Pop() Push(2) Push(3) Pop() Push(4) Pop() Pop() Push(5) After the completion of all operation the number of elements present in stack is?
1
2
3
4
39. Which of the following is not an inherent application of stack?
Reversing a string
Evaluation of postfix expression
Implementation of recursion
Job scheduling
40. The type of expression in which operator succeeds its operands is?
Infix Expression
Prefix Expression
Postfix Expression
Both Prefix and Postfix Expressions
41. Assume that the operators + - X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^ X + -. The postfix expression for the infix expression a + b X c � d ^ e ^ f is?
abc X+ def ^^ �
abc X+ de^f^ �
ab+c Xd � e ^f^
-+aXbc^ ^def
42. If the elements A B C and D are placed in a stack and are deleted one at a time what is the order of removal?
ABCD
DCBA
DCAB
ABDC
43. A linear collection of data elements where the linear node is given by means of pointer is called?
Linked list
Node list
Primitive list
Unordered list
44. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation which of the following operation can be implemented in O(1) time? i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list a)
I and II
I and III
I II and III
I II and IV
45. In linked list each node contains a minimum of two fields. One field is data field to store the data second field is?
Pointer to character
Pointer to integer
Pointer to node
Node
46. What would be the asymptotic time complexity to add a node at the end of singly linked list if the pointer is initially pointing to the head of the list?
O(1)
O(n)
?(n)
?(1)
47. What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?
O(1)
O(n)
O(n2)
O(n3)
48. What would be the asymptotic time complexity to find an element in the linked list?
O(1)
O(n)
O(n2)
O(n4)
49. The concatenation of two lists can be performed in O(1) time. Which of the following variation of the linked list can be used?
Singly linked list
Doubly linked list
Circular doubly linked list
Array implementation of list
50. Which of the following c code is used to create new node?
ptr = (NODE*)malloc(sizeof(NODE))
ptr = (NODE*)malloc(NODE)
ptr = (NODE*)malloc(sizeof(NODE*))
ptr = (NODE)malloc(sizeof(NODE))
51. A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as _____________
Queue
Stack
Tree
Linked list
52. The data structure required for Breadth First Traversal on a graph is?
Stack
Array
Queue
Tree
53. A queue follows __________
FIFO (First In First Out) principle
LIFO (Last In First Out) principle
Ordered array
Linear tree
54. Circular Queue is also known as ________
Ring Buffer
Square Buffer
Rectangle Buffer
Curve Buffer
55. If the elements A B C and D are placed in a queue and are deleted one at a time in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
56. A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?
Queue
Circular queue
Dequeue
Priority queue
57. A normal queue if implemented using an array of size MAX_SIZE gets full when?
Rear = MAX_SIZE � 1
Front = (rear + 1)mod MAX_SIZE
Front = rear + 1
Rear = front
58. Queues serve major role in ______________
Simulation of recursion
Simulation of arbitrary linked list
Simulation of limited resource allocation
Simulation of heap sort
59. Which of the following is not the type of queue?
Ordinary queue
Single ended queue
Circular queue
Priority queue
60. This set of Data Structure Interview Questions & Answers focuses on Singly Linked List Operations � 1 . 1. A linear collection of data elements where the linear node is given by means of pointer is called?
Linked list
Node list
Primitive list
Unordered list
61. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation which of the following operation can be implemented in O(1) time? i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list a) b) c) I II and III d) I II and IV
I and II
I and III
I II and III
I and III
62. In linked list each node contains a minimum of two fields. One field is data field to store the data second field is?
Pointer to character
Pointer to integer
Pointer to node
None
63. What would be the asymptotic time complexity to find an element in the linked list?
O(1)
O(n)
O(n2)
O(n4)
64. The concatenation of two lists can be performed in O(1) time. Which of the following variation of the linked list can be used?
Singly linked list
Doubly linked list
Circular doubly linked list
Array implementation of list
65. Consider the following definition in c programming language. struct node { int data struct node * next } typedef struct node NODE NODE *ptr Which of the following c code is used to create new node?
ptr = (NODE*)malloc(sizeof(NODE))
ptr = (NODE*)malloc(NODE)
ptr = (NODE*)malloc(sizeof(NODE*))
ptr = (NODE)malloc(sizeof(NODE))
66. What kind of linked list is best to answer questions like What is the item at position n?
Singly linked list
Doubly linked list
Circular linked list
Array implementation of linked list
67. Linked lists are not suitable for the implementation of ___________
Insertion sort
Radix sort
Polynomial manipulation
Binary search
68. Linked list is considered as an example of ___________ type of memory allocation.
Dynamic
Static
Compile time
Heap
69. In Linked List implementation a node carries information regarding ___________
Data
Link
Data and Link
Node
70. Linked list data structure offers considerable saving in _____________
Computational Time
Space Utilization
Space Utilization and Computational Time
Speed Utilization
71. Which of the following points is/are not true about Linked List data structure when it is compared with an array?
Arrays have better cache locality that can make them better in terms of performance
It is easy to insert and delete elements in Linked List
Random access is not allowed in a typical implementation of Linked Lists
Access of elements in linked list takes less time than compared to arrays
72. What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head == NULL) return fun1(head->next) printf("%d " head->data) }
Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of Linked List
Prints alternate nodes in reverse order
73. Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
Insertion Sort
Quick Sort
Heap Sort
Merge Sort
Submit