Data Structures and Algorithms-Mcap 1201-2023
Data Structures and Algorithms-Mcap 1201-2023
Data Structures and Algorithms-Mcap 1201-2023
Group – A
(Multiple Choice Type Questions)
MCAP 1201 1
MCA/2ND SEM/MCAP 1201/2023
(viii) What is the search complexity in direct addressing?
(a) O(n) (b) O(log n)
(c) O(n log n) (d) O(1).
(ix) 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 (d) Information given is insufficient.
(x) What is the number of moves required to solve Tower of Hanoi problem for k
disks?
(a) 2k – 1 (b) 2k + 1
(c) 2 + 1
k (d) 2k – 1.
Group- B
2. (a) Represent the following polynomial 5x5 + 4x2 – 25x + 10 with array(s). Write an
algorithm to read such a polynomial, take derivative of the polynomial and print
the result. [(CO4)(Apply/IOCQ)]
(b) Let A be a two-dimensional array declared as follows:
A: array [1…10] [1…15] of character;
Assuming that each character takes one memory location, the array is stored in
row-major order and the first element of the array is stored in location 100,
what is the address of the element A[i][j]? [(CO1)(Apply/IOCQ)]
(c) What are header nodes or list headers? Why is it desirable sometimes to use
header nodes? [(CO4)(Understand/LOCQ)]
6 + 3 + (1 + 2) = 12
3. (a) The running time of an algorithm T(n), where n is the input size is given by
T ( n ) = 8 T ( n/2 ) + qn, if n > 1
= p, if n = 1
where, p and q are constants. Find the time complexity of the algorithm in
asymptotic notation. [(CO2)(Analyze/IOCQ)]
(b) Show that 4n2 + 7 = O(n3). [(CO2)(Apply/IOCQ)]
(c) Work out the computational complexity of the following piece of code:
for( count = 1; count<= n; count *= 2 ) {
for( i = 0; i < count; i++ ) {
for( j = 0; j < n; j += 2 ) {
... /* constant number of operations */}
}
} [(CO2)(Evaluate/HOCQ)]
4 + 3 + 5 = 12
Group - C
4. (a) What is a circular queue? What are the advantages of circular queue over linear
queue? Write append and serve functions for a circular queue.
[(CO3)(Understand/LOCQ)]
MCAP 1201 2
MCA/2ND SEM/MCAP 1201/2023
(b) With the help of stack convert the following infix expression to corresponding
postfix expression:
(assume ^ is the exponentiation operator) [(CO4)(Apply/IOCQ)]
((5 + 3) * 4) – 2 ^ 3 ^ 2
(1 + 2 + 3) + 6 = 12
5. (a) State the Towers of Hanoi problem. Devise a solution to the Towers of Hanoi
problem clearly explaining the pre-condition and post-condition for any
algorithm you write. Derive the time complexity of your algorithm in terms of
O-notation. [(CO2)(Apply/IOCQ)]
(b) A queue Q containing n items and an empty stack S are given. It is required to
transfer all the items from the queue to the stack, so that the item at the front of
the queue is on the top of the stack, and the order of all the other items is
preserved. How can this be done in O(n) time using only a constant amount of
additional storage. [(CO2)(Create/HOCQ)]
(1 + 4 + 1) + 6 = 12
Group – D
6. (a) What are two ways of representing binary trees in the memory? Which one do
you prefer and why? [(CO4)(Evaluate/HOCQ)]
(b) Given a binary tree whose inorder and preorder traversals are given by
Inorder: E I C F B G D J H K
Preorder: B C E I F D G H J K
Draw the tree. What will be the post order traversal of the binary tree?
[(CO1)(Apply/IOCQ)]
(c) In a full binary tree of height k, how many internal nodes are present?
[(CO1)(Analyze/IOCQ)]
(3 + 2) + (3 + 2) + 2 = 12
7. (a) Construct a max heap with the following entries, in the order stated
26, 33, 35, 29, 42, 72. [(CO5)(Apply/IOCQ)]
(b) Insert the following keys in order to build them into an AVL tree:
A Z B Y C X D W E V F
Clearly mention the different rotations used and the balance factor of each node.
[(CO4)(Apply/IOCQ)]
(c) Insert the following entries, in the order stated, into an initially empty B-tree of
order 4.
A G F B K D H M J E S I R X C L N T U P
[(CO4)(Apply/IOCQ)]
4 + 4 + 4 = 12
Group - E
8. (a) Consider a hash table with size = 10. Using quadratic probing, insert the keys 27,
72, 63, 42, 36, 18, 29, and 101 into the table. Take c1 = 1 and c2 = 3.
[(CO4)(Apply/IOCQ)]
MCAP 1201 3
MCA/2ND SEM/MCAP 1201/2023
(b) An article in a professional journal stated, “This recursive process [merge sort]
takes time O(nlogn), and so runs 64 times faster than the previous method
[insertion sort] when sorting 256 numbers.” Criticize this statement.
[(CO3)(Analyze/IOCQ)]
(c) Write Dijkstra's algorithms using greedy approach for finding shortest path in a
graph. [(CO3)(Apply/IOCQ)]
5 + 4 + 3 = 12
9. (a) How is the idea of sentinel used to increase the efficiency of linear search? What
are the best and worst case complexities of linear search with sentinel?
[(CO6)(Analyze/IOCQ)]
(b) Trace the action of radix sort on the following list of seven numbers considered
as three-digit integers:
265, 337, 357, 295, 193, 125, 224. [(CO4) (Apply/IOCQ)]
(c) Suppose that L1 and L2 are lists containing n1 and n2 integers, respectively, and
both lists are already sorted into numerical order. Use the idea of binary search
to describe how to find the median of the n1 + n2 integers in the combined lists.
[(CO6) (Create/HOCQ)]
(2 + 2) + 4 + 4 = 12
*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question; HOCQ: Higher Order
Cognitive Question.
MCAP 1201 4