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

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI

Work Integrated Learning Programmes (WILP) Division


M. Tech -Data Science and Engineering
I Semester 2018-19 (Oct 2018 to Mar 2019)
Mid-Semester MAKEUP Examination

Course No : DSEABZG519/DSEADZG519/ DSEAHZG519


Course Name : Data Structure and Algorithm Design
Nature of Exam : Closed Book No. of page: 2
Max Marks : 30 No. of questions: 4
Duration : 1-Hour & 30-Minutes
Date of Exam : 5th January 2019 Session: FN.

Note:
1. Please read and follow all the instructions given on the cover page of the answer booklet.
2. All questions have part A and part B.
3. Start each answer from a fresh page. All parts of a question should be answered consecutively.
4. Please ensure that your answers cover necessary technical details, avoiding unnecessary text and
diagrams.

1) a. Assume that you are given two algorithms (ALG1 and ALG2) for solving a problem of size 2M
utmost 7.ALG1 takes n2 steps to solve the problem whereas ALG2 takes 2n /4 steps to solve the
same problem. Which algorithm would you choose and why?

b. Insert data {9, 56, 11, 86, 55, 22, 10, 4, 39, 49, 82, 13, 40, 31, 28} into a hash table implemented 4M
using open addressing technique. Assume the buckets to have 3 slots each. Make use of the hash
function h(X) = X mod 9. Apply the linear probing technique for collision resolutions. Also show
the collisions by specifically highlighting them.

c. If a data structure supports an operation OP such that a sequence of n OP’s take (n log n) time 2M
to perform in the worst case, then what will be the
 Amortized time of a OP operation
 Worst case running time possible for a single OP operation.

2) a. Consider the following binary heap. 5M

Page 1 of 2
 Suppose that the last operation performed in the binary heap above was inserting the key
x. Find all possible values of x. Give suitable explanations

 Suppose that you delete the maximum key from the binary heap above. Find all keys that
are involved in one (or more) comparisons. Show the comparisons.

b. Suppose that you are using a doubly linked list, maintaining a reference to the first and last node 2M
in the list, along with its size, to implement the operations below
 addFirst(item): prepend the item to the beginning of the list
 get(i) :return the item at position i in the list
 set(i, item) :replace position i in the list with the item
 removeLast() delete and return the item at the end of the list
What is the worst-case running time of each of the operation above?

3) a. Calculate the page rank of the 4 pages using 6 iterations for the following graph 6M

Assume the damping factor d=0.7 and initial page rank of each page is 1

b. Given an adjacency matrix representation of a graph .What is the 2M


 Time taken to compute the out-degree of all vertices?
 Time taken to compute in-degree of all vertices?
 Time taken to compute in-degree and out-degree of a single vertex?

4) a. Write an algorithm to reverse the order of elements on a stack S using two additional stacks. 4M

b. Find the preorder traversal for the binary tree using 3M


Inorder traversal : D B E A F G C H
Postorder traversal: D E B F G H C A
Also construct the tree.

Page 2 of 2

You might also like