DSA Model QP

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

MAILAM ENGINEERING COLLEGE, MAILAM

(Approved by AICTE, New Delhi, Permanently Affiliated to Anna University Chennai,


Accredited by NBA and TCS)
Department of Information Technology

Model Sub/
Test CD3291 / Data Structures and Algorithms
Exam Code:

Year / SEM: II/III Date: 16.12.22

Time: 3 hrs Marks: 100

PART – A (10X2=20)
C Leve
Q.no Questions
O l
1. Write a member function to find the greater of two numbers
1 1
using 'this' pointer. Write the various asymptotic notations.

1. State the advantage of ADT. What values are returned


during the following series of stack operations, if executed

2 1 2. upon an initially empty stack? push(5), push(3), pop(),


push(2), push(8), pop(), pop(), push(9), push(1), pop(),
push(7), push(6), pop(), pop(), push(4), pop(), pop(). (2)

2. What is the postfix equivalent of the infix expression a + b * c +


2 1 3.
(d * e + f) * g ?

3. What ere the disadvantage of linked list over arrays? Give a


2 1 4.
recursive method for removing all the elements from a stack.

What is priority queue? What are the ways to implement


3 1 5.
priority queue? What is meant Rehashing?

6. What are the running times of Quick Sort and Merge Sort for
3 1
presorted input? Define internal and external sorting.

What is meant AVL Tree? What is the minimum number of nodes


4 1 7.
in AVL tree of height 15?

What do you mean by level of the tree?


For the tree
a. List the sibilings for the node E
b. Compute the height.

4 1 8.
Give the ways in which a graph can be represented with an
4 1 9.
example. What is meant by strongly connected in a graph?

If G is a simple undirected graph with 12 vertices and 3

4 1 10. connected components, what is the largest number of edges


it might have?

PART – B
(5X13=65)
(i) Describe a recursive function for converting a string of digits

2 into the integer it represents. For example, 13531 represents the


integer 13,531. (7)
1 11.a
(ii) Write a Python program that inputs a list of words, separated

1 by whitespace, and outputs how many times each word appears


in the list.(6)
(i) What is meant Dijikstras Algorithm? Write an Algorithm using
1
python. (5)
4
(ii) Given a graph and a source vertex in the graph, find
the shortest paths from the source to all vertices in the given
graph. (8)
11.b
2

(i) Describe a recursive algorithm that counts the number of


nodes in a singly linked list. (6)
2 12.a
2
(ii) What is meant Queue ADT? Explain in detail about Queue ADT
using Linked List implementation. (7)
(i) What is meant Greedy Method? Explain in detail about
Huffman Coding Algorithm with an example. (7)
4
(ii) Draw an adjacency matrix and adjacency list for the
representation of the following undirected graph. (6)

1 12.b

3 13.a (i) Write a routine for Insertion Sort. Sort the following sequence
1
using Insertion Sort 3,10,4,2,8,6,5,1 (7)
2 (ii) Illustrate the execution of the in-place heap-sort algorithm on
the following input sequence: (2,5,16,4,10,23,39,18,26,15).
(i) State the complexity of binary search? Distinguish between
linear search and binary search. State and explain the algorithms
3
1 for both the search with example.(7)
(ii) What are the advantage of separate chaining and Linear
Probing? Given input {4371,1323,6173,4199,9679, 1989} and a
13.b
hash function h(x)= x(mod10),show the resulting.(6)

2 a) open hash table


b) Closed hash table using Linear Probing
c) Closed hash table using Quadratic probing
d) Double hashing
(i) How to insert and delete an element into a binary search tree
and write down the code for the insertion routine. Construct a
2
binary search tree by inserting 30, 10, 4, 19, 62, 35, 28, 73 into
14.a an initially empty tree. (7)
4
(ii) Show the results of inserting 3, 2, 1, 4, 5, 6, 7, 9, 6, 15, 14,
1 13, 12, 11, 10, 8 and 9 in to initially empty AVL tree. Explain
with neat algorithm. (6)
(i) What is a B-tree? Mention the properties that a B-tree holds.
1 Create a B-Tree of order 5 by inserting the following elements:
4
3,14,7,1,8,5,11,17,13,6,23,12,20,26,4,16,18,24,25, and 19 (7)

14.b (ii) Draw the result of inserting, into an initially empty order-7 B-
tree, entries with keys
1
(4,40,23,50,11,34,62,78,66,22,90,59,25,72,64,77,39,12),
in this order. (6)

(i) What is meant Topological Sorting? State and explain


topological sort with the following graph and write its Algorithm.
1
(5)

15.a
4

(ii) Apply an appropriate algorithm to find the shortest path from


3 ‘A’ to every other node of A. For the given graph. (Or) Formulate
an algorithm to find the shortest path using Dijkstra’s algorithm
and explain with the following example. (8)
1 (i) From the figure in what order are the vertices using BFS
and DFS starting from vertex A (Tree Traversal)? Where a choice
4 exists use alphabetical order. (7)

15.b

(ii) What is meant Dynamic Programming? Explain in detail about


1
the longest common subsequence algorithm with an example. (6)
PART – C
(1X15=15)
(i) What is meant Directed Acyclic Graph(DAG) with its
1
implementation. (5)
(ii) What is meant kruskals Algorithm? Explain in detail about
4 16.a
1 Kruskals Algorithm with an example. (5)
(iii)What is meant Complexity classes? Explain in detail about
1
Introduction to Complexity classes and Intractability. (5)

4 (i) What is meant Dynamic Programming? Illustrate the working


of Floyd-Warshall's algorithm (Transitive Closure Algorithm) with
the following example. (8)

(ii)What is meant Prims Algorithm? Explain in detail the Prim’s


16.b algorithm for finding minimum spanning tree and apply to the
following graph. (7)

CO1: Explain abstract data types


CO2: Design, implement, and analyze linear data structures, such as lists, queues, and stacks,
according to the needs of different applications
CO3: Design, implement, and analyze efficient tree structures to meet requirements such as
searching, indexing, and sorting
CO4: Model problems as graph problems and implement efficient graph algorithms to solve them

K1 – Remember, K2 – Understand, K3 – Apply, K4 – Analysis, K5 – Evaluate, K6 - Create

Prepared By Verified By Approved by

Subject In-charge Batch Co-ordinator HOD/IT

You might also like