SSM INSTITUTE OF ENGINEERING AND TECHNOLOGY ,DINDIGUL
DEPARTMENT OF AIDS & CSBS
Subject: AD3251 DATA STRUCTURES AND DESIGN
Year/Sem: I/II
Max Marks: 60
INTERNAL TEST –II
Answer key
Part- A (10 * 2=20)
Define Hash function. Give two examples
1 The hash function is a function that takes a key and returns an index into the hash table.
. Example: h(key)=key% Table size
H(key)=(hash (key) + f(i))% Table Size
Illustrate collision during hashing? what is the reason for collision in hashing techniques?
2 Collision refers to the situation where more than one key is mapped to the same address by
. the hash function.
A collision occurs when more than one value to be hashed by a particular hash function hash
to the same slot in hash table.
What are the application of binary trees?
3 a. Expression trees are used in compilers.
.
b. Trees are used in hierchical database management system
c. Binary search trees support search, insertion and deletion on a collection of items in O(log
n)
d. Priority Queue supports search and deletion of minimum on a collection of items in
logarithmic time.
Mention some Problems for which heaps are more applicable.
4 A heap tree can be used for many different purposes including the following:
. Djiktra’s Algorithm, which is used to find the shortest path between two nodes in
a graph.
Heap Sort algorithm
Implementing priority queues.
Finding the smallest or largest element in an array.
What is the advantage of using multi-way search tree?
5 1. Multi-way trees are often required fewer internal nodes than binary search trees to store
. items.
2. They are efficient for all dictionary methods
3. They are easy to maintain and balance.
4. They provide fast information retrieval.
Give the balance factor of an AVL tree.
6 Balanced Factor = Height of Left Sub tree – Height of right sub tree
. Maintaining a balanced tree, ensure its height never exceeds 1.44 log n.
Explain the Topological sort.
7 Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that
. for every directed edge u-v, vertex u comes before v in the ordering.
Topological Sorting for a graph is not possible if the graph is not a DAG
Define shortest path problem.
8 It involves finding the most efficient path between two vertices (or nodes) in a graph, such that
. the sum of the weights of its constituent edges is minimized.
What do you mean by DAG?
9 A directed acyclic graph (DAG) is a directed graph with no directed cycles.
.
1 Differentiate between Weakly connected graph and Strongly connected graph
0 A directed graph is strongly connected if there is a path between any two vertices in the graph.
. A directed graph is weakly connected if there is a path between any two vertices in the underlying
undirected graph.
Part B (16*2=32)
1 What is collision? How is it overcome using separate chaining? Using hash function key
1) mod 7 hash the keys 50,700,76,85,92,73,101.Use separate chaining when collision occurs.
a) 16 marks
Collision - 2 mark
How is it overcome using separate chaining - 2 mark
Using hash function - 12 marks
OR
Write a program to perform searching operations using linear and binary search. Give
b example 16 marks
) Linear search program - 8 marks
Binary search program - 8 marks
1 What is heap?How to build a max heap and min heap? Give example 8 marks
2) Heap - 2 marks
a) Min-Heap with example - 3 marks
i) Max Heap with example – 3 marks
Construct an expression tree for the expression (a+b*c)+(d*e+1)*g).Give the outputs when
you apply Preorder,inorder and Postorder traversals. 8
i marks
i
) Constructing expression tree - 5 marks
Output for Preorder traversal - 1 mark
Output for Preorder traversal - 1 mark
Output for Preorder traversal - 1 mark
OR
Construct a binary search tree by inserting 3,1,4,9,6,5,2,8 and 7 into an initially empty
b tree.show the results of deleting the nodes 1,6,and 7 one after the other of the constructed
) tree 8
i marks
)
1. Constructing the Binary Search Tree (BST): 5 marks
2. Deleting Nodes: 3 marks
Construct an AVL tree by interesting 4,1,2,5,6,17,3,and 7 into an initially empty tree.show
the results of deleting the nodes 1,6,and 7 one after the other of the constructed tree.Give the
i order of visiting the nodes by applying the postorder traversal algorithm 8
i
) marks
1. Constructing the AVL Tree: 4 marks
2. Deleting Node 1: 1 mark
3. Deleting Node 6: 1 mark
Deleting Node 7: 1 mark
4. Order of Visiting Nodes (Postorder Traversal): 1 mark
1 Define minimum spanning tree. Explain Kruskal’s algorithm to find the minimum spanning
3) tree of a graph. Apply the algorithm to find the minimum spanning tree of the given graph
a) 8 marks
Minimum Spanning Tree (MST) 2 marks
Kruskal’s Algorithm - 2 marks
Applying algorithm to find the minimum spanning tree - 8 marks
OR
List the Properties of greedy approach.Explain Dijkstra’s algorithm to find the shortest path
b from a source vertex and analyze the time complexity of the approach. Apply the same on the
) graph given below to find the shortest path from vertex ‘a’. 8
marks
Properties of greedy approach - 2 marks
Dijkstra’s algorithm - 2 marks
Applying algorithm to find the shortest path - 4 marks
Faculty Incharge HoD/AIDS&CSBS