Data Structure Mcqs 110
Data Structure Mcqs 110
Data Structure Mcqs 110
System.out.println(arr[2]);
System.out.println(arr[4]);
a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
System.out.println(arr[5]);
a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException
a) Create
b) Push
c) Evaluation
d) Pop
a) Create
b) Push
c) Evaluation
d) Pop
16. In a stack, if a user tries to remove an element from empty stack it is called _________
a) Underflow
b) Empty collection
c) Overflow
d) Garbage Collection
17. Pushing an element into stack already having five elements and stack size of 5, then stack becomes
a) Overflow
b) Crash
c) Underflow
d) User flow
18. Entries in a stack are “ordered”. What is the meaning of this statement?
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: (()(())(())) are:
a) 1
b) 2
c) 3
d) 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?
a) 1
b) 2
c) 3
d) 4 or more
a) 1
b) 40
c) 74
d) -18
23. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
b) AB + CD* E – F **G /
c) AB + CD* E – *F *G /
d) AB + CDE * – * F *G /
24. The data structure required to check whether an expression contains balanced parenthesis is?
a) Stack
b) Queue
c) Array
d) Tree
25. What data structure would you mostly likely see in a non recursive implementation of a recursive
algorithm?
a) Linked List
b) Stack
c) Queue
d) Tree
26. The process of accessing data stored in a serial access memory is similar to manipulating data on a
________
a) Heap
b) Binary Tree
c) Array
d) Stack
a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d) ABCD+/*
28. Which data structure is needed to convert infix notation to postfix notation?
a) Branch
b) Tree
c) Queue
d) Stack
a) -/*^ACBDE
b) -ABCD*^DE
c) -A/B*C^DE
d) -A/BC*^DE
a) X
b) X+S
c) S
d) XS
View Answer
a) Queue
b) Stack
c) Array
d) List
32. Convert the following infix expressions into its equivalent postfix expressions
(A + B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – / G +)
b) (A B D +⋀ E F – / G +)
c) (A B D ⋀ + E F/- G +)
d) (A B D E F + ⋀ / – G +)
33. Which of the following statement(s) about stack data structure is/are NOT correct?
d) Null link is present in the last node at the bottom of the stack
34. Which of the following is not an inherent application of stack?
a) Reversing a string
c) Implementation of recursion
d) Job scheduling
35. The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression
36. 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?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
37. 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 a ?
a) Queue
b) Stack
c) Tree
d) Linked list
38. The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
39. A queue follows __________
c) Ordered array
d) Linear tree
a) Ring Buffer
b) Square Buffer
c) Rectangle Buffer
d) Curve Buffer
41. 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?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
42. A data structure in which elements can be inserted or deleted at/from both the ends but not in the
middle is?
a) Queue
b) Circular queue
c) Dequeue
d) Priority queue
a) Simulation of recursion
a) Ordinary queue
c) Circular queue
d) Priority queue
45. A linear collection of data elements where the linear node is given by means of pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list
View Answer
46. 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?
a) I and II
b) I and III
c) I, II and III
d) I, II and IV
View Answer
47. In linked list each node contain minimum of two fields. One field is data field to store the data
second field is?
a) Pointer to character
b) Pointer to integer
c) Pointer to node
d) Node
48. 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?
a) O(1)
b) O(n)
c) θ(n)
d) θ(1)
49. What would be the asymptotic time complexity to insert an element at the front of the linked list
(head is known)?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
50. What would be the asymptotic time complexity to find an element in the linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n4)
51. What would be the asymptotic time complexity to insert an element at the second position in the
linked list?
a) O(1)
b) O(n)
c) O(n2)
d) O(n3)
52. The concatenation of two list can performed in O(1) time. Which of the following variation of linked
list can be used?
a) Singly linked list
struct node
int data;
NODE *ptr;
a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));
55. What kind of linked list is best to answer question like “What is the item at position n?”
56. Linked lists are not suitable to for the implementation of?
a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search
a) Dynamic
b) Static
c) Compile time
d) Heap
a) Data
b) Link
d) Node
a) Computational Time
b) Space Utilization
d) Speed Utilization
60. Which of the following points is/are not true about Linked List data structure when it is compared
with array?
a) Arrays have better cache locality that can make them better in terms of performance
d) Access of elements in linked list takes less time than compared to arrays
61. 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);
62. Which of the following sorting algorithms can be used to sort a random linked list with minimum
time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort
63. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not
given, can we delete the node X from given linked list?
64. You are given pointers to first and last nodes of a singly linked list, which of the following operations
are dependent on the length of the linked list?
a) 2
c) 0 or 1 or 2
d) 0 or 1
66. What is/are the disadvantages of implementing tree using normal arrays?
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement
67. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l
68. If the tree is not a complete binary tree then what changes can be made for easy access of children
of a node in the array?
a) every node stores data saying which of its children exist in the array
69. Consider a situation of writing a binary tree into a file with memory storage efficiency in mind, is
array representation of tree is good?
a) yes because we are overcoming the need of pointers and so space efficiency
70. What is the time complexity of pre-order traversal in the iterative fashion?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
71. What is the space complexity of the post-order traversal in the recursive fashion? (d is the tree
depth and n is the number of nodes)
a) O(1)
b) O(nlogd)
c) O(logd)
d) O(d)
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
73. Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The in order
traversal of the same binary tree is B, E, A, D, C. The level order sequence for the binary tree is
_________
a) A, C, D, B, E
b) A, B, C, D, E
c) A, B, C, E, D
d) D, B, E, A, C
74. Consider the following data and specify which one is Preorder Traversal Sequence, Inorder and
Postorder sequences.
S1: N, M, P, O, Q
S2: N, P, Q, O, M
S3: M, N, O, P, Q
75. In postorder traversal of binary tree right subtree is traversed before visiting root.
a) True
b) False
76. What is the possible number of binary trees that can be created with 3 nodes, giving the sequence N,
M, L when traversed in post-order.
a) 15
b) 3
c) 5
d) 8
77. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal will be
________
a) T Q R S O P
b) T O Q R P S
c) T Q O P S R
d) T Q O S P R
78. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a valid
post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?
79. Which of the following pair’s traversals on a binary tree can build the tree uniquely?
b) pre-order traversal
c) post-order traversal
d) in-order traversal
81. The maximum number of nodes in a tree for which post-order and pre-order traversals may be equal
is ______
a) 3
b) 1
c) 2
d) any number
82. The steps for finding post-order traversal are traverse the right subtree, traverse the left subtree or
visit the current node.
a) True
b) False
83. The pre-order and in-order are traversals of a binary tree are T M L N P O Q and L M N T O P Q.
Which of following is post-order traversal of the tree?
a) L N M O Q P T
b) N M O P O L T
c) L M N O P Q T
d) O P L M N Q T
84. For a binary tree the first node visited in in-order and post-order traversal is same.
a) True
b) False
his set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Graph”.
data-structure-questions-answers-graph-q2
a) B and E
b) C and D
c) A and E
d) C and B
87. For the given graph(G), which of the following statements is true?
data-structure-questions-answers-graph-q3
a) G is a complete graph
b) G is not a connected graph
88. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
data-structure-questions-answers-graph-q5
a) True
b) False
90. In a simple graph, the number of edges is equal to twice the sum of the degrees of the vertices.
a) True
b) False
View Answer
91. A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
a) 15
b) 3
c) 1
d) 11
View Answer
92. If a simple graph G, contains n vertices and m edges, the number of edges in the Graph
G'(Complement of G) is ___________
a) (n*n-n-2*m)/2
b) (n*n+n+2*m)/2
c) (n*n-n-2*m)/2
d) (n*n-n+2*m)/2
93. Which of the following properties does a simple graph not hold?
a) Must be connected
b) Must be unweighted
94. What is the maximum number of edges in a bipartite graph having 10 vertices?
a) 24
b) 21
c) 25
d) 16
96. For a given graph G having v vertices and e edges which is connected and has no cycles, which of the
following statements is true?
a) v=e
b) v = e+1
c) v + 1 = e
d) v = e-1
97. Which of the following statements for a simple graph is correct?
data-structure-questions-answers-graph-q2
a) B and E
b) C and D
c) A and E
d) C and B
View Answer
99. For the given graph(G), which of the following statements is true?
data-structure-questions-answers-graph-q3
a) G is a complete graph
View Answer
100. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
data-structure-questions-answers-graph-q5
a) True
b) False
102. In a simple graph, the number of edges is equal to twice the sum of the degrees of the vertices.
a) True
b) False
103. A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
a) 15
b) 3
c) 1
d) 11
104 If a simple graph G, contains n vertices and m edges, the number of edges in the Graph
G'(Complement of G) is ___________
a) (n*n-n-2*m)/2
b) (n*n+n+2*m)/2
c) (n*n-n-2*m)/2
d) (n*n-n+2*m)/2
105. Which of the following properties does a simple graph not hold?
a) Must be connected
b) Must be unweighted
a) 24
b) 21
c) 25
d) 16
108. For a given graph G having v vertices and e edges which is connected and has no cycles, which of
the following statements is true?
a) v=e
b) v = e+1
c) v + 1 = e
d) v = e-1
109. The time complexity to calculate the number of edges in a graph whose information in stored in
form of an adjacency matrix is ____________
a) O(V)
b) O(E2)
c) O(E)
d) O(V2)
110. For the adjacency matrix of a directed graph the row sum is the _________ degree and the column
sum is the ________ degree.
a) in, out
b) out, in
c) in, total
d) total, out