Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Data Structures and Algorithms-Mcap 1201-2023

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

MCA/2ND SEM/MCAP 1201/2023

MCA/2ND SEM/MCAP 1201/2023

DATA STRUCTURES AND ALGORITHMS


(MCAP 1201)

Time Allotted : 3 hrs Full Marks : 70


Figures out of the right margin indicate full marks.
Candidates are required to answer Group A and
any 5 (five) from Group B to E, taking at least one from each group.
Candidates are required to give answer in their own words as far as practicable.

Group – A
(Multiple Choice Type Questions)

1. Choose the correct alternative for the following: 10 × 1 = 10


(i) What is the outcome of the prefix expression + - * 3 2 / 8 4 1 ?
(a) 12 (b) 11
(c) 5 (d) 4.
(ii) Which type of linked list does not store NULL in next field of the last node?
(a) Singly linked list (b) Circular linked list
(c) Doubly linked list (d) All of these.
(iii) What is the minimum number of stacks needed to implement a queue? Consider
the situation where no other data structure like arrays, linked list is available to
you.
(a) 1 (b) 2
(c) 3 (d) 4
(iv) The time complexity of enqueue operation in Queue is _______.
(a) O(1) (b) O(n)
(c) O(log n) (d) O(n log n)
(v) Which rotation is done when a new node is inserted in the right sub-tree of the
right sub-tree of the critical node?
(a) LL (b) LR
(c) RL (d) RR.
(vi) In a max-heap, element with the greatest key is always in which node?
(a) Leaf node (b) First node of left sub tree
(c) Root node (d) First node of right sub tree.
(vii) Leaves of which of the following trees are at the same level?
(a) Binary tree (b) B-tree
(c) AVL-tree (d) Expression tree.

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

Cognition Level LOCQ IOCQ HOCQ


Percentage distribution 9.38 69.79 20.83

Course Outcome (CO):

After the completion of the course students will be able to


MCAP1201.1 Define the basic data structures and their operations.
MCAP1201.2 Evaluate algorithms in terms of time and memory complexity of basic operations.
MCAP1201.3 Understand the significance and context of application of different algorithm design
techniques.
MCAP1201.4 Understand the significance and utility of different data structures and the context of their
application.
MCAP1201.5 Evaluate solutions of a problem with different data structures and thereby understand how to
select suitable data structures for a solution.
MCAP1201.6 Create or design an algorithm to aid in the solution of a real world problem.

*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question; HOCQ: Higher Order
Cognitive Question.

MCAP 1201 4

You might also like