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

1

Software Engineering Department 17/06/2021


CENG 383 Final Exam Part II

Q1) Consider following algorithm


function(A[1..n])
{
if n = 1 then return;
for i := 1 to n/2 :
A[i] := A[i]+i;
function (A[1..n/2]);
}
a)(4p)Express the Time complexity of above algorithm as a recurrence
b)(5p)Find the closed form of recurrence by using substitution, iteration method or recursion tree method.
Q2) Consider the following code fragment.
for i=1 to n/2:
for j=i to n-i :
for k=1 to j do
print(“hi”)
Let T(n) denote the number of times “hi” is printed as a function of n.
(a)(8p) Express T(n) as three nested summations, and simplfy them by showing steps
(b)(8p) Find a finction f(n) such that T ( n )=Θ(f (n))
2

Q3) 40p

startingNode: (Sum of All digits of your student id) mod 12


a)(5p) give representation of this graph as an adjacency matrix representation or adjacency list representation.
b)(5p) Write the output of graph traversal by Depth First Search startingNode as the source vertex,
c)(10p) Using Prim’s Algorithm draw Minimum Spanning Tree of above graph
d)(10p) Illustrate the execution of Kruskal’s Algorithm. Show the final Minimum Spanning Tree.
e)(10p) Illustrate the execution of Dijkstra’s algorithm using startingNode as the start vertex on the following
graph. Show the priorities before each dequeue operation.

Priority after dequeueing


Vertex 1 2 3 4 5 6 7 8 9 10 11 12
1
2
3
4
5
6
7
8
9
10
11
12

You might also like