DSA Model
DSA Model
Write thevarious
asymptotic notations.
2. State the advantage of ADT. What values are returned during the following series of stack
operations, if executed 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)
5. What is priority queue? What are the ways to implement priority queue? What is meant
Rehashing?
6. What are the running times of Quick Sort and Merge Sort for presorted input? Define internal and
external sorting.
9. Give the ways in which a graph can be represented with an example. What is meant by strongly
connected in a graph?
10.
PART B
11.a)(i) What parameters should be sent to the range constructor, to produce a range with values
50, 60, 70, 80? (2) Describe a recursive function for converting a string of digits into the integer it
represents. For example, 13531 represents the integer 13,531. (7)
(ii) Write a Python program that inputs a list of words, separated by whitespace, and outputs how
many times each word appears in the list.(6)
12.a) (i) Describe a recursive algorithm that counts the number of nodes in a singly linked list. (6)
(ii) What is meant Stack ADT? Explain in detail about Stack ADT using Linked List implementation.
(7)
(Or)
b)(i) What is meant Greedy Method? Explain in detail about Huffman Coding Algorithm with an
example. (7)
(ii) Draw an adjacency matrix and adjacency list for the representation of the following undirected
graph. (6)
13.a) (i) Write a routine for Insertion Sort. Sort the following sequence using Insertion Sort
3,10,4,2,8,6,5,1 (7)
(Or)
13.b)(i) State the complexity of binary search? Distinguish between linear search and binary search.
State and explain the algorithms 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 hash function h(x)= x(mod10),show the resulting.(6)
14.a)(i) How to insert and delete an element into a binary search tree and write down the code for
the insertion routine. Construct a binary search tree by inserting 30, 10, 4, 19, 62, 35, 28, 73 into an
initially empty tree. (7)
(ii) Show the results of inserting 3, 2, 1, 4, 5, 6, 7, 9, 6, 15, 14, 13, 12, 11, 10, 8 and 9 in to initially
empty AVL tree. Explain with neat algorithm. (6)
(Or)
14.b)(i) What is a B-tree? Mention the properties that a B-tree holds. Create a B-Tree of order 5 by
inserting the following elements: 3,14,7,1,8,5,11,17,13,6,23,12,20,26,4,16,18,24,25, and 19 (8)
(ii) What is meant binary heap and its types of Heap? State and explain binary Heap. Also analyze the
time complexity of the algorithm. (5)
15. a)(i) From the figure in what order are the vertices using BFS and DFS starting from vertex A?
Where a choice exists use alphabetical order. (7)
(ii) Apply an appropriate algorithm to find the shortest path from ‘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. (6)
(Or)
15.b) (i) What is meant Topological Sorting? State and explain topological sort with the following
graph. (7)
(ii) What is meant Dynamic Programming? Explain in detail about the longest common subsequence
algorithm with an example. (6)
PART C
16.a) (i) What is meant Directed Acyclic Graph(DAG) with implementation. (5)
(ii) What is meant kruskals Algorithm? Explain in detail about Kruskals Algorithm with an example.
(5)
(iii)What is meant Complexity classes? Explain in detail about Introduction to Complexity classes and
Intractability.
(Or)
16.b) (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 algorithm for finding minimum
spanning tree and apply to the following graph. (7)