Data Structures MCQs: Arrays & Lists
Data Structures MCQs: Arrays & Lists
(MCQ) UNIT I
1. Which of these best describes an array?
A data structure that shows a hierarchical behaviour
Answer: b
Answer: c
int arr[];
Answer: c
int[] arr;
int arr[[]];
int[][]arr;
d) int[[]] arr;
Answer: c
5. a) 3 and 5
5 and 3
2 and 4
4 and 2
Answer: a
6. a) 4
ArrayIndexOutOfBoundsException
InavlidInputException
Answer: c
Compile-time
Run-time
Not an error
Answer: b
Binary trees
Scheduling of processes
Caching
Spatial locality
Answer: d
Answer: d
There are chances of wastage of memory space if elements inserted in an array are lesser than the
allocated size
Answer: b
15
19
11
60
Answer: d
-1
Answer: a
randomly
sequentially
exponentially
d) logarithmically
Answer: a
Fixed size
There are chances of wastage of memory space if elements inserted in an array are lesser than the
allocated size
Answer: d
15. What is the time complexity of inserting at the end in dynamic arrays?
O(1)
O(n)
O(logn)
Answer: d
16. What is the time complexity to count the number of elements in the linked list?
O(1)
O(n)
O(logn)
O(n2)
Answer: b
Answer: c
18. What is the space complexity for deleting a linked list?
O(1)
O(n)
O(logn)
Answer: a
Answer: d
Find and return the position of the given element in the list
Answer: c
Answer: d
22. What is the worst case time complexity of inserting a node in a doubly linked list?
O(nlogn)
O(logn)
O(n)
5
d) O(1)
Answer: c
23. a) head-0-1-2-3-4-5-6-tail
head-1-2-3-4-5-6-tail
head-6-1-2-3-4-5-0-tail
head-0-1-2-3-4-5-tail
Answer: c
a) Return the element at the tail of the list but do not remove it
Return the element at the tail of the list and remove it from the list
Return the last but one element from the list but do not remove it
Return the last but one element at the tail of the list and remove it from the list
Answer: b
25. a) head-6-1-2-3-4-5-tail
head-6-1-2-3-4-tail
head-1-2-3-4-5-6-tail
head-1-2-3-4-5-tail
Answer: b
26. What differentiates a circular linked list from a normal linked list?
You cannot have the ‘next’ pointer point to null in a circular linked list
You may or may not have the ‘next’ pointer point to null in a circular linked list
Answer: c
Answer: b
28. What is the time complexity of searching for an element in a circular linked list?
O(n)
O(nlogn)
O(1)
O(n2)
Answer: a
29. Which of the following application makes use of a circular linked list?
Answer: c
Returns the data and deletes the node at the end of the list
Returns the data and deletes the node from the beginning of the list
Answer: d
Returns the data and deletes the node at the end of the list
Returns the data and deletes the node from the beginning of the list
Answer: b
We can traverse the whole circular linked list by starting from any point
Answer: b
33. Consider a small circular linked list. How to detect the presence of cycles in this list effectively?
Keep one node as head and traverse another temp node till the end to check if its ‘next points to head
Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer
advancing by one node at a time
Circular linked list itself represents a cycle. So no new cycles cannot be generated
Answer: b
34. 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
Answer: a
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?
Answer: b
In linked list each node contain 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
Answer: c
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)
Answer: c
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)
Answer: a
39. What would be the asymptotic time complexity to find an element in the linked list?
O(1)
O(n)
O(n2)
O(n4)
Answer: b
What would be the asymptotic time complexity to insert an element at the second position in the
linked list?
O(1)
O(n)
O(n2)
9
d) O(n3)
Answer: a
The concatenation of two list can performed in O(1) time. Which of the following variation of
linked list can be used?
Answer: c
ptr = (NODE*)malloc(sizeof(NODE));
ptr = (NODE*)malloc(NODE);
ptr = (NODE*)malloc(sizeof(NODE*));
ptr = (NODE)malloc(sizeof(NODE));
Answer: a
CS8391 Data Structures
Anna University :: Regulations 2017 Multiple Choice Questions
(MCQ) UNIT II LINEAR DATA STRUCTURES – STACKS,
QUEUES
1. Process of inserting an element in stack is called
Create
Push
Evaluation
Pop
Answer: b
Create
Push
Evaluation
Pop
Answer: d
Underflow
Empty collection
Overflow
Garbage Collection
Answer: a
4. Pushing an element into stack already having five elements and stack size of 5, then stack becomes
Overflow
Crash
Underflow
d) User flow
Answer: a
Answer: d
Answer: d
7. 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:
Answer: c
8. 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?
Answer: b
2
9. What is the value of the postfix expression 6 3 2 4 + – *?
40
74
-18
Answer: d
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?
Answer: d
11. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
AB+CD*E–F**G/
AB+CD*E–*F*G/
AB+CDE*–*F*G/
Answer: c
12. The data structure required to check whether an expression contains balanced parenthesis is?
Stack
Queue
Array
Tree
Answer: a
⤀ĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀЀĀȀ⤀ĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀЀĀȀ⤀ĀᜀĀ
ᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀЀĀȀ⤀ĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀĀᜀ
What data structure would you mostly likely see in a non recursive implementation of a recursive
algorithm?
Linked List
Stack
Queue
Tree
Answer: b
14. The process of accessing data stored in a serial access memory is similar to manipulating data on a
Heap
Binary Tree
Array
Stack
Answer: d
*AB/CD+
AB*CD/+
A*BC+/D
ABCD+/*
Answer: b
16. Which data structure is needed to convert infix notation to postfix notation?
Branch
Tree
Queue
Stack
Answer: d
a) -/*^ACBDE
-ABCD*^DE
-A/B*C^DE
-A/BC*^DE
Answer: c
X+S
Answer: a
+ pq – *rt
– +pqr * t
– +pq * rt
– + * pqrt
Answer: c
Queue
Stack
Array
List
Answer: b
It is ignored
It is ignored
Answer: c
(a+b)*(c+d)
ab+c*
+ab
abc+*
Answer: a
O(N log N)
O(N)
O(N2)
O(M log N)
Answer: b
25. a) abc*+de*+
abc+*de*+
a+bc*de+*
abc*+(de)*+
Answer: a
26. a) -ab-c
b) ab – c –
6
– -abc
-ab-c
Answer: b
27. a) abc^/d-
ab/cd^-
ab/^cd-
abcd^/-
Answer: a
28. Which of the following statement is incorrect with respect to infix to postfix conversion algorithm?
operator is placed in the stack when the stack operator has lower precedence
Answer: c
29. In infix to postfix conversion algorithm, the operators are associated from?
right to left
left to right
centre to left
centre to right
Answer: b
30. a) ab*+cd/
ab+*cd/
abc*+/d
abc+*d/
Answer: d
31. a) ab*cdef/^*g-h+
abcdef^/*g*h*+
abcd*^ed/g*-h*+
abc*de^fg/*-*h+
Answer: b
32. a) abc^de-fg+*^*+i-
abcde^-fg*+*^h*+i-
abcd^e-fgh*+^*+i-
ab^-dc*+ef^gh*+i-
Answer: c
33. From the given Expression tree, identify the correct postfix expression from the list of options.
ab*cd*+
ab*cd-+
abcd-*+
Answer: b
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 ?
Queue
Stack
Tree
Linked list
Answer: a
35. The data structure required for Breadth First Traversal on a graph is?
Stack
Array
Queue
Tree
Answer: c
8
36. A queue follows
Ordered array
Linear tree
Answer: a
Ring Buffer
Square Buffer
Rectangle Buffer
Curve Buffer
Answer: a
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
Answer: a
A data structure in which elements can be inserted or deleted at/from both the ends but not in the
middle is?
Queue
Circular queue
Dequeue
Priority queue
Answer: c
40. A normal queue, if implemented using an array of size MAX_SIZE, gets full when
Rear = MAX_SIZE – 1
Front = rear + 1
Rear = front
Answer: a
Simulation of recursion
Answer: c
Ordinary queue
Circular queue
Priority queue
Answer: b
Array
List
Heap
Tree
Answer: d
Huffman codes
Answer: c
45. What is the time complexity to insert a node based on key in a priority queue?
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: c
Answer: c
A low priority process might have to wait indefinitely for the CPU
If the system crashes, the low priority systems may be lost permanently
Interrupt handling
Indefinite blocking
Answer: c
Easy to implement
Answer: d
49. What is the time complexity to insert a node based on position in a priority queue?
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: c
A queue with insert/delete defined for both front and rear ends of the queue
Answer: a
Answer: b
Answer: d
53. a) 10 30 10 15
20 30 40 15
20 30 40 10
10 30 40 15
Answer: d
12
54. Which of the following properties is associated with a queue?
Answer: b
55. In a circular queue, how do you increment the rear end of the queue?
rear++
(rear+1) % CAPACITY
(rear % CAPACITY)+1
rear–
Answer: b
56. What is the term for inserting into a full queue known as?
overflow
underflow
Answer: a
O(logn)
O(nlogn)
O(n)
O(1)
Answer: d
58. a) Dequeue
b) Enqueue
13
Return the front element
Answer: c
easier computations
Answer: a
O(n)
O(nlogn)
O(logn)
O(1)
Answer: a
a) 3 3
36
66
10 6
Answer: a
CS8391 Data Structures
Anna University :: Regulations 2017 Multiple Choice Questions
(MCQ) UNIT III NON LINEAR DATA STRUCTURES – TREES
1. What is the maximum number of children that a binary tree node can have?
Answer: c
Binary tree
Fibonacci tree
Answer: a
Answer: c
depth-first traversal
breadth-first traversal
random traversal
Answer: b
Answer: b
Answer: c
n+O(n)
2n+O(n)
n/2
Answer: b
O(N)
O(√N)
O(N2)
O(log N)
Answer: d
9. How many orders of traversal are applicable to a binary tree (In General)?
1
Answer: d
If binary trees are represented in arrays, what formula can be used to locate a left child, if the node
has an index i?
2i+1
2i+2
2i
4i
Answer: a
(i+1)/2
(i-1)/2
i/2
2i/2
Answer: b
12. Which of the following properties are obeyed by all three tree – traversals?
Answer: a
The preorder traversal of a binary tree is 1, 2, 5, 3, 4. The inorder traversal of the same binary tree is 2, 5, 1,
4, 3.
a)
3
b)
c)
Answer: d
2, 7, 2, 6, 5, 11, 5, 9, 4
2, 7, 5, 2, 6, 9, 5, 11, 4
2, 5, 11, 6, 7, 4, 9, 5, 2
Answer: a
2, 7, 2, 6, 5, 11, 5, 9, 4
2, 7, 5, 2, 6, 9, 5, 11, 4
2, 5, 11, 6, 7, 4, 9, 5, 2
Answer: c
16. What is the time complexity of pre-order traversal in the iterative fashion?
O(1)
O(n)
O(logn)
O(nlogn)
Answer: b
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)
O(1)
O(nlogd)
O(logd)
O(d)
Answer: d
18. To obtain a prefix expression, which of the tree traversals is used?
Level-order traversal
Pre-order traversal
Post-order traversal
In-order traversal
Answer: b
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,C,D,B,E
A,B,C,D,E
A,B,C,E,D
D,B,E,A,C
Answer: b
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
Answer: c
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.
15
Answer: c
22. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal will be
TQRSOP
TOQRPS
TQOPSR
TQOSPR
Answer: c
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?
Answer: d
Which of the following pair’s traversals on a binary tree can build the tree uniquely?
Answer: b
pre-order traversal
post-order traversal
in-order traversal
Answer: a
The maximum number of nodes in a tree for which post-order and pre-order traversals may be
equal is
3
any number
Answer: b
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?
LNMOQPT
NMOPOLT
LMNOPQT
OPLMNQT
Answer: a
28. Find the postorder traversal of the binary tree shown below.
PQRSTUVWX
WRSQPVTUX
SWTQXUVRP
Answer: c
6, 2, 5, 7, 11, 2, 5, 9, 4
6, 5, 2, 11, 7, 4, 9, 5, 2
2, 7, 2, 6, 5, 11, 5, 9, 4
Answer: a
2, 7, 2, 6, 5, 11, 5, 9, 4
2, 7, 5, 2, 11, 9, 6, 5, 4
2, 5, 11, 6, 7, 4, 9, 5, 2
Answer: b
7
What is the space complexity of the in-order traversal in the recursive fashion? (d is the tree depth
and n is the number of nodes)
O(1)
O(nlogd)
O(logd)
O(d)
Answer: d
O(1)
O(n)
O(logn)
O(nlogn)
Answer: b
33. Which of the following graph traversals closely imitates level order traversal of a binary tree?
Binary Search
Answer: b
In a binary search tree, which of the following traversals would print the numbers in the ascending
order?
Level-order traversal
Pre-order traversal
Post-order traversal
In-order traversal
Answer: d
35. The number of edges from the root to the node is called of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: b
36. The number of edges from the node to the deepest leaf is called of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: a
Answer: a
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled
from right to left
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled
from left to right
Answer: c
39. What is the average case time complexity for finding the height of the binary tree?
h = O(loglogn)
h = O(nlogn)
h = O(n)
h = O(log n)
Answer: d
Hierarchical structure
Faster search
Router algorithms
Answer: d
41. In a full binary tree if number of internal nodes is I, then number of leaves L are?
L=2*I
L=I+1
L=I–1
L=2*I–1
Answer: b
42. In a full binary tree if number of internal nodes is I, then number of nodes N are?
N=2*I
N=I+1
N=I–1
N=2*I+1
Answer: d
43. In a full binary tree if there are L leaves, then total number of nodes N are?
N=2*L
N=L+1
N=L–1
N=2*L–1
Answer: d
10
44. Which of the following is incorrect with respect to binary trees?
Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k
Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes
Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))
Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))
Answer: d
45. Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M
a)
b)
Answer: d
46. Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.
a)
b)
c)
Answer: b
47. Construct a binary tree using inorder and level order traversal given below.
Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
a)
b)
Answer: a
The left and right sub-trees should also be binary search trees
Answer: d
49. What is the speciality about the inorder traversal of a binary search tree?
Answer: b
Inorder traversal
Postorder traversal
Answer: c
Inorder traversal
Postorder traversal
Answer: a
52. What are the worst case and average case complexities of a binary search tree?
O(n), O(n)
O(logn), O(logn)
O(logn), O(n)
O(n), O(logn)
Answer: d
12
53. What are the conditions for an optimal binary search tree and what is its advantage?
The tree should not be modified and you should know how often the keys are accessed, it improves the
lookup cost
You should know the frequency of access of the keys, improves the lookup time
The tree can be modified and you should know the number of elements in the tree before hand, it improves
the deletion time
The tree should be just modified and improves the lookup time
Answer: a
a)
b)
c)
Answer: c
55. Which of the following is not the self balancing binary search tree?
AVL Tree
2-3-4 Tree
Splay Tree
Answer: b
56. The binary tree sort implemented using a self – balancing binary search tree takes time is
worst case.
O(n log n)
O(n)
O(n2)
O(log n)
Answer: a
An AVL tree is a self – balancing binary search tree, in which the heights of the two child sub trees of
any node differ by
At least one
At most one
Two
At most two
Answer: b
B-tree
Answer: d
2-3 tree
AA tree
Treap
Answer: c
Priority queue
Hash table
Heap sort
Answer: a
In which of the following self – balancing binary search tree the recently accessed element can be
accessed quickly?
AVL tree
AA tree
14
Splay tree
Answer: c
62. The minimum height of self balancing binary search tree with n nodes is
log2(n)
2n + 1
2n – 1
Answer: a
Answer: a
to save memory
to simplify storing
Answer: a
i.
ii.
only i
only i and ii
Answer: b
15
66. What is the maximum height of an AVL tree with p nodes?
log(p)
log(p)/2
P⁄2
Answer: b
Given an empty AVL tree, how would you construct AVL tree when a set of numbers are given
without performing any rotations?
find the median of the set of elements given, make it as root and construct the tree
Answer: b
68. What maximum difference in heights between the leafs of a AVL tree is possible?
0 or 1
atmost 1
Answer: a
Height(w-left), x-height
Height(w-right), x-height
Height(w-left), x
Height(w-left)
Answer: a
AVL tree store balance factor in every node which costs space
Answer: b
71. Which of the following is the most widely used external memory data structure?
AVL tree
B-tree
Red-black tree
Answer: b
72. B-tree of order n is a order-n multiway tree in which each non-root node contains
c) at least 2n keys
Answer: d
a) 255
b) 63
c) 127
d) 188
Answer: a
Five node splitting operations occurred when an entry is inserted into a B-tree. Then how many
nodes are written?
14
17
11
Answer: c
AVL
AA
2-3
Red-Black
Answer: d
76. Figure shown below is B-tree of order 5. What is the result of deleting 130 from the tree?
a)
b)
c)
Answer: c
77. What is the best case height of a B-tree of order n and which has k keys?
logn (k+1) – 1
nk
logk (n+1) – 1
klogn
Answer: a
Answer: a
79. In a max-heap, element with the greatest key is always in the which node?
Leaf node
root node
Answer: c
O(log n)
O(h)
O(n)
Answer: c
81. The worst case complexity of deleting any arbitrary node value element from heap is
O(logn)
O(n)
O(nlogn)
O(n2)
Answer: a
Priority queue
Stack
Normal Array
Answer: a
83.
If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of
root node after second iteration if leaf node (value 100) is chosen to replace the root at start.
2
100
17
Answer: a
84.
If we implement heap as maximum heap , adding a new node of value 15 to the left most node of right
subtree . What value will be at leaf nodes of the right subtree of the heap.
15 and 1
25 and 1
3 and 1
Answer: a
An array consists of n elements. We want to create a heap using the elements. The time complexity of
building a heap will be in order of
O(n*n*logn)
O(n*logn)
O(n*n)
Answer: b
CS8391 Data Structures
Anna University :: Regulations 2017 Multiple Choice Questions
(MCQ) UNIT IV NON LINEAR DATA STRUCTURES – GRAPHS
Answer: a
B and E
C and D
A and E
Answer: d
G is a complete graph
Answer: c
(n*(n+1))/2
(n*(n-1))/2
a) True
b) False
Answer: a
a) 15
b) 3
c) 1
d) 11
Answer: b
If a simple graph G, contains n vertices and m edges, the number of edges in the Graph
G'(Complement of G) is
(n*n-n-2*m)/2
(n*n+n+2*m)/2
(n*n-n-2*m)/2
(n*n-n+2*m)/2
Answer: a
Must be connected
Must be unweighted
Answer: a
a) 24
2
21
25
16
Answer: c
Answer: b
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?
v=e
v = e+1
v+1=e
v = e-1
Answer: b
For which of the following combinations of the degrees of vertices would the connected graph be
eulerian?
1,2,3
2,3,4
2,4,5
1,3,5
Answer: a
Multi Graph
Regular Graph
Simple Graph
d) Complete Graph
Answer: b
Incidence Matrix
No way to represent
Answer: c
The number of possible undirected graphs which may have self loops but no multiple edges and
have n vertices is
2((n*(n-1))/2)
2((n*(n+1))/2)
2((n-1)*(n-1))/2)
2((n*n)/2)
Answer: d
Given a plane graph, G having 2 connected component, having 6 vertices, 7 edges and 4 regions.
What will be the number of connected components?
Answer: b
17. Number of vertices with odd degrees in a graph having a eulerian walk is
Can’t be predicted
either 0 or 2
Answer: d
4
18. How many of the following statements are correct?
Answer: b
19. What is the number of vertices of degree 2 in a path graph having n vertices,here n>2.
n-2
Answer: a
Answer: d
21. In the given graph which edge should be removed to make it a Bipartite Graph?
A-C
B-E
C-D
Answer: a
What would the time complexity to check if an undirected graph with V vertices and E edges is
Bipartite or not given its adjacency matrix?
O(E*E)
O(V*V)
5
O(E)
O(V)
Answer: b
23. Which of the following is not a topological sorting of the given graph?
ABCDEF
ABFEDC
ABECFD
Answer: d
24. With V(greater than 1) vertices, how many edges at most can a Directed Acyclic Graph possess?
a) (V*(V-1))/2
b) (V*(V+1))/2
c) (V+1)C2
d) (V-1)C2
Answer: a
a) cubic
b) quadratic
c) linear
d) logarithmic
Answer: c
26. If there are more than 1 topological sorting of a DAG is possible, which of the following is true.
Answer: b
27. What sequence would the BFS traversal of the given graph yield?
AFDBCE
CBAFED
ABDCEF
Answer: c
28. a) 0 2 3 1 4
03241
02341
03214
Answer: b
Answer: d
What is the value of the sum of the minimum in-degree and maximum out-degree of an Directed
Acyclic Graph?
Depends on a Graph
Answer: b
CS8391 Data Structures
Anna University :: Regulations 2017 Multiple Choice Questions
(MCQ) UNIT V SEARCHING, SORTING AND HASHING
TECHNIQUES
When the list has only a few elements and When performing a single search in an unordered list
Answer: d
O(nlogn)
O(logn)
O(n)
O(1)
Answer: d
O(nlogn)
O(logn)
O(n)
O(1)
Answer: c
4. What is the best case and worst case complexity of ordered linear search?
O(nlogn), O(logn)
O(logn), O(nlogn)
O(n), O(1)
O(1), O(n)
Answer: d
Answer: a
Answer: b
Answer: b
8. Given an input arr = {2,5,7,99,899}; key = 899; What is the level of recursion?
Answer: c
2
Given an array arr = {45,77,89,90,94,99,100} and key = 99; what are the mid values(corresponding
array elements) in the first and second levels of recursion?
90 and 99
90 and 94
89 and 99
89 and 94
Answer: a
10. What is the worst case complexity of binary search using recursion?
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: b
11. What is the average case time complexity of binary search using recursion?
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: b
Union of intervals
Debugging
Answer: d
Greedy algorithm
Dynamic programming
Answer: b
Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the element is
found?
Answer: d
Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid
values(corresponding array elements) generated in the first and second iterations?
90 and 99
90 and 100
89 and 94
94 and 99
Answer: a
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: b
Answer: a
Answer: b
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: d
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: d
Which of the following is not an advantage of optimised bubble sort over other sorting techniques in
case of sorted elements?
It is faster
Answer: c
5
The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many
iterations will be done to sort the array?
Answer: a
23. What is the best case efficiency of bubble sort in the improvised version?
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: c
The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many
iterations will be done to sort the array with improvised version?
Answer: b
Answer: a
26. In the following scenarios, when will you use selection sort?
The input is already sorted
Answer: c
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: d
28. What is the advantage of selection sort over other sorting techniques?
It is scalable
Answer: a
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: d
It is not scalable
Answer: b
The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort
respectively are,
5 and 4
4 and 5
2 and 4
2 and 5
Answer: a
The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of
iterations in selection sort and bubble sort respectively are,
5 and 4
1 and 4
0 and 4
4 and 1
Answer: d
O(nlogn)
O(logn)
O(n)
O(n2)
Answer: d
Answer: b
8
35. Statement 1: Shell sort is a stable sorting algorithm.
Answer: b
Shell sort is applied on the elements 27 59 49 37 15 90 81 39 and the chosen decreasing sequence of
increments is (5,3,1). The result after the first iteration will be
27 59 49 37 15 90 81 39
27 59 37 49 15 90 81 39
27 59 39 37 15 90 81 49
15 59 49 37 27 90 81 39
Answer: c
Answer: d
insertion sort
selection sort
quick sort
Answer: a
5-ordered
Answer: d
If Hibbard increments (h1= 1, h2= 3, h3= 7, …, hk = 2k–1) are used in a Shell sort implementation,
then the best case time complexity will be
O(nlogn)
O(n)
O(n2)
O(logn)
Answer: a
41. Records R1, R2, R3,.. RN with keys K1, K2, K3,.. KN are said to be h-ordered, if
Answer: d
Shell sort’s passes completely sort the elements before going on to the next-smallest gap while Comb
sort’s passes do not completely sort the elements
Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap like in
Comb sort
Comb sort’s passes completely sort the elements before going on to the next-smallest gap like in Shell sort
Shell sort’s passes do not completely sort the elements before going on to the next-smallest gap while
Comb sort’s passes completely sort the elements
Answer: a
a) Heap sort
Smooth sort
Quick sort
Answer: d
44. What is the worst case time complexity of LSD radix sort?
a) O(nlogn)
b) O(wn)
c) O(n)
d) O(n + w)
Answer: b
a) (w/logR)
b) N(w/logR)
c) (w/log(RN))
d) (wN/log(N))
Answer: a
Answer: b
Heap sort
Selection sort
48. Which of the following should be used to sort a huge database on a fixed-length key field?
Insertion sort
Merge sort
Quick sort
Answer: c
49. Which of the following is a combination of LSD and MSD radix sorts?
Flash sort
Answer: a
50. Which of the following is true for the LSD radix sort?
Answer: b
hashing by division
hashing by multiplication
universal hashing
open addressing
Answer: c
52. Which hash function satisfies the condition of simple uniform hashing?
h(k) = lowerbound(km)
h(k)= upperbound(mk)
h(k)= lowerbound(k)
h(k)= upperbound(k)
Answer: a
53. a) 14963
14392
12784
14452
Answer: d
h(k) = k/m
h(k) = k mod m
h(k) = m/k
h(k) = m mod k
Answer: b
2p – 1
2p
Answer: a
open addressing
universal hashing
hashing by division
hashing by multiplication
Answer: b
57. Using division method, in a given hash table of size 157, the key of value 172 be placed at position
19
72
15
17
Answer: c
58. How many steps are involved in creating a hash function using a multiplication method?
Answer: d
Answer: a
using constant
simple multiplication
Answer: c
61. What is the table size when the value of p is 7 in multiplication method of creating hash functions?
14
128
49
127
Answer: b
123
456
70
Answer: d
63. What is the average retrieval time when n keys hash to the same slot?
Theta(n)
Theta(n2)
Theta(nlog n)
Big-Oh(n2)
Answer: a