Paper 3
Paper 3
l
)
7 (a) The BFS algorithm has been used to produce the Your Roll No......,........
shortest paths from a node s to all other nodes in
Sr. No. of Question Paper: 4523 E
a graph G. Can the Dijkstra's algorithm be used
in place of BFS? In a different scenario, the Unique Paper Code 32 I
Dijkstra's algorithm has been used to produce the
shortest paths from a node s to all other nodes in Namc ol'the P aper 4) slgn an d Analysis ol
q'
a graph C'. Can BFS be used in place of the lgorithrns
Dijkstra's algorithm? Explain your answers for Name of the Course I].Sc. (ll) Comp utcr Scicn ce
both the scenarios. (6)
Sem(]ster IV
(b) Write a pseudocode for the memorized recursive
Duration : 3 Hours Maximum Marks : 75
algorithm to compute the nth Fibonacci number.
What would be its tirne complexity'? (4)
Instructions for Candiclatcs
(1000) P.T.O
4523 2 4s23 7
) )
(b) Discuss the running time of the following snippet (ii) The maximum element found in step I is
for (i= l, i<=n, i++) This algorithm is given as input a list already
sorted in decreasing order. What would be the
for (=1, j<:n, j = 2 *j)
time complexity of the algorithm on this input?
(3)
count++ Explain. (4)
then the capacity of all bottles. They want to decision tree for a comparison sort? Use this
fill L litres of water in minimum number of observation to derive a lower bound on the
bottles. Describe a greedy algorithm to help number of comparisons performed by a
them fill U litres of water in minimum number of comparison sort in the worst case.
bottles. (3)
(b) Show that at most 3* floor (n/2 ) comparisons are
(d) Will the greedy strategy with the greedy parameter sufficient to find both the minimum and maximum
being value per unit weight of the items yield an in a given array of size n. (4)
optimal solution for the 0-l knapsack problem?
Justify. (3)
P.T.O.
4523 .,
4523 6
) )
(e) Can dynamic programming be applied to all
subarray in the array -1,2, 3, -2, 5, 6, 7' -8 is
optimization problems? Why or why not? (3)
9 (which is the sum of the subarray 2' 3, -2, 5,
-6,7). Complete the following Dynamic
Programming solution for the above problem: (0 Let G be a tree-graph. Further, let T" and To be
the trees produced by perforrning BPS and DFS
: At0l
DP[O] respectively on G. Can To and T,, be different
Fori=lton trees? Why or why not? (4)
(b) A of n numbers
student was asked to sort a list
in decreasing order. The student writes an
algorithm which works iteratively as follows' ln
every iteration, the lbllowing two steps are done:
Specify whether the above graph is bipartite or
(i) Linear search is used to find the maximum not. If yes, give the partition, else justify'
element in the portion of the array which
is not yet sorted.
P.T,O.
4523 4 4523 5
) )
(i) We are given a weighted graph G in which edge (a) Let G = (V,E) be a dire*ed unweighred graph.
weights are not necessarily distinct. Can graph G
Given two vertices s and t in V, what is the time
have more than one minimum spanning tree
required to determine if there exists at least
(MST)? If yes, give an example, else justify.
one s-t path in G? Can we use the DFS algorithm
(4)
to find the shortest-path distance from the s to
O Show that in any subtree of a max-heap, root of
the subtree contains the largest value occurring t? If yes. justily. otherwise give a counter
anywhere in that subtree. (4)
example. (6)
P.T.O