Introduction to Algorithms, Third Edition



Download 4,84 Mb.
Pdf ko'rish
bet59/618
Sana07.04.2022
Hajmi4,84 Mb.
#534272
1   ...   55   56   57   58   59   60   61   62   ...   618
Bog'liq
Introduction-to-algorithms-3rd-edition

Exercises
4.1-1
What does F
IND
-M
AXIMUM
-S
UBARRAY
return when all elements of
A
are nega-
tive?
4.1-2
Write pseudocode for the brute-force method of solving the maximum-subarray
problem. Your procedure should run in
‚.n
2
/
time.
4.1-3
Implement both the brute-force and recursive algorithms for the maximum-
subarray problem on your own computer. What problem size
n
0
gives the crossover
point at which the recursive algorithm beats the brute-force algorithm? Then,
change the base case of the recursive algorithm to use the brute-force algorithm
whenever the problem size is less than
n
0
. Does that change the crossover point?
4.1-4
Suppose we change the definition of the maximum-subarray problem to allow the
result to be an empty subarray, where the sum of the values of an empty subar-


4.2
Strassen’s algorithm for matrix multiplication
75
ray is
0
. How would you change any of the algorithms that do not allow empty
subarrays to permit an empty subarray to be the result?
4.1-5
Use the following ideas to develop a nonrecursive, linear-time algorithm for the
maximum-subarray problem. Start at the left end of the array, and progress toward
the right, keeping track of the maximum subarray seen so far. Knowing a maximum
subarray of
AŒ1 : : j 
, extend the answer to find a maximum subarray ending at in-
dex
j
C
1
by using the following observation: a maximum subarray of
AŒ1 : : j
C
1
is either a maximum subarray of
AŒ1 : : j 
or a subarray
AŒi : : j
C
1
, for some
1
i
j
C
1
. Determine a maximum subarray of the form
AŒi : : j
C
1
in
constant time based on knowing a maximum subarray ending at index
j
.

Download 4,84 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   618




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish