0% found this document useful (0 votes)
2 views4 pages

Paper 3

The document is a question paper for a computer science course, covering algorithms and data structures. It includes questions on BFS and Dijkstra's algorithms, dynamic programming, sorting techniques, and graph theory. The paper consists of multiple sections with various problems to solve, requiring pseudocode, explanations, and algorithm analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Paper 3

The document is a question paper for a computer science course, covering algorithms and data structures. It includes questions on BFS and Dijkstra's algorithms, dynamic programming, sorting techniques, and graph theory. The paper consists of multiple sections with various problems to solve, requiring pseudocode, explanations, and algorithm analysis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

4523 8 [This question paper contains 8 printed pages.

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

Write your Roll No. on the top immediately on receipt


of this question paper.

2. Question No. I is cornpulsory


3. Attempt any four of Questions Nos. 2 to 7

(a) Use the Master's Theorem to give tight asymptotic


bounds for the recurrence T(n): 8T(n/2) + Q(nr).
(3)

(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

of code : placed at the beginning of the not-yet-sorted


portion of the array.
count = 0

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)

(c) A team of explorers is visiting the Sahara desert.


As the weather is very hot, they are having n 6. (a) (i) What is the smallest possible depth of a leaf
bottles of different sizes to carry water and keep in a decision tree for a comparison sort?
them hydrated. In covering few kilometres, they Name a sorting technique to which this
used all of their water but tbrtunately found smallest depth would correspond. (6)
a water source nearby. This water source is
having only L litres of water which is way lesser
(ii) What is the minimum number of leaves in the

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)

DP[i] = max(A[i], (4)


(g) Why is the worst-case running time for bucket
-) sort 0(n2)? What changes would you make to the
(a) How many topological orderings does the following
5
algorithm so that its worst-case running time
graph have? SPecifY all of them. (6)
becomes O(nl gn)'? (4)

(h) Consider the following graPh (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)

(b) Suppose we perform a sequence of stack


2 (a) Consider the scheduling problem wherein you are operations on a stack whose size never exceeds
given a single resource and a set of requests k. After every k operations, we make a copy of
having deadlines. A request is said to be late be the entire stack for backup purposes. Show that
Iate if it misses the deadline. your goal is to the cost of n stack operations, including copying
minimize the maximum lateness. With respect to a
the stack, is O(n) by assigning suitable amortized
schedule S, idle time is defined as the time during
costs to the various stack operations. (4)
which the resource is idle, in between two
requests. S is said to have an inversion when
request i has been scheduled before j and 4 (a) Show that for an n-element max heap (having
d(i) > d(J), where d(i) and d(i) are the deadlines distinct elements) represented through an array,
of the requests i and j respectively. Argue that all the leaves are the nodes indexed by floor (n/2 + l),
schedules with no idle time and no inversions have floor (n/2 + 2),........, n. What would be the location
the same maximum lateness. (6) of the minimum clement in the above heap?
(b) For each of the following sorting algorithms, merge (6)
sort and insertion sort, discuss whether or not it is
(b) Civen an array A of n integers, you need to find
(i) stable the maximum sum of any contiguous subarray. For
(ii) in-place g) instance, the maximum sum of any contiguous

P.T.O

You might also like