Paper Daa
Paper Daa
2208 C
nique l'aper Code 32341 401
Semester IV
G) Merge Sort
to sort n elements
following algorithms
(i) Maxheapify
(4)
2208 3
algorithm. (4)
F(n) F(n-1)+n.
=
n>l
F(1) = 1
Justify. (3)
P.T.O
2208
G2
V
X
y
P.T.O.
2 2
Lag2
2208
2
said to have an inversion when request i has
hee.
cen
schcduled before j, and d(i) dý) (d{k)
being the
deadline of a request k). Argue that all
schedules
with idle time and
no no inversions have the same
maximum lateness.
(6)
(a) Consider the
Heapsort Algorithm. Fill in the
missing details correctly.
(3)
Assume A[1...length] be the array to be sorted
MaxHeapify(A,i)
1-2
F2*i+1
ifl<=
A.heapsize and A[l]>A[r]
largest==1
else largest = i
if
r=A.heapsize and A[r] >A[largest]
largest =Fr
iflargest!=i
exchange A[i] and A[largest]
Maxheapify(A, _
BuildMaxHeap(A)
A.heapsize = A.length
for i =
MaxHcapify (A,i)
Heapsort(A)
BuildMaxHeap
for i= (A)
A.lengthdownto
Cxchange A[_]with2 A[i]
A.heapsize= A.heapsize -1
MaxHeapify (A,_)
7
2208
6. (a) In randomized-select
algorithm
tne
replace
is used. If
we
Pal t i o n
subroutine P.T.O.
2.T
208
8
partition
subroutine which
randomized partition by
a
list as pivot and
and
element of the
chooses the last
as the
select algorithm
call the modified algorithm
on the running time of
What affect does
it have
the select algorithm? (3)
a topological
directed graph having
(6) Show that any
(4)
must be acyclic.
ordering
valid Red
6, 2, 8, 3, 10; give
a
elements
c) For the (3)
Black tree.
minimized. (3)
(cDiscuss the running time of the following function
func(A)
for i 0 to A.length -2
for j = i+1 to A.length - 1
if(Aj-1]> A[j])
exchange (Aj-1] and AD]) (4)
(1400)