Introduction to Algorithms, Third Edition



Download 4,84 Mb.
Pdf ko'rish
bet36/618
Sana07.04.2022
Hajmi4,84 Mb.
#534272
1   ...   32   33   34   35   36   37   38   39   ...   618
Bog'liq
Introduction-to-algorithms-3rd-edition

recurrence equation
or
recurrence
, which describes the overall
running time on a problem of size
n
in terms of the running time on smaller inputs.
We can then use mathematical tools to solve the recurrence and provide bounds on
the performance of the algorithm.
7
We shall see in Chapter 3 how to formally interpret equations containing

-notation.
8
The expression
d
x
e
denotes the least integer greater than or equal to
x
, and
b
x
c
denotes the greatest
integer less than or equal to
x
. These notations are defined in Chapter 3. The easiest way to verify
that setting
q
to
b
.p
C
r/=2
c
yields subarrays
AŒp : : q
and
AŒq
C
1 : : r
of sizes
d
n=2
e
and
b
n=2
c
,
respectively, is to examine the four cases that arise depending on whether each of
p
and
r
is odd or
even.


2.3
Designing algorithms
35
5
2
4
7
1
3
2
6
2
5
4
7
1
3
2
6
2
4
5
7
1
2
3
6
1
2
2
3
4
5
6
7
merge
merge
merge
sorted sequence
initial sequence
merge
merge
merge
merge
Figure 2.4
The operation of merge sort on the array
A
D h
5; 2; 4; 7; 1; 3; 2; 6
i
. The lengths of the
sorted sequences being merged increase as the algorithm progresses from bottom to top.
A recurrence for the running time of a divide-and-conquer algorithm falls out
from the three steps of the basic paradigm. As before, we let
T .n/
be the running
time on a problem of size
n
. If the problem size is small enough, say
n
c
for some constant
c
, the straightforward solution takes constant time, which we
write as
‚.1/
. Suppose that our division of the problem yields
a
subproblems,
each of which is
1=b
the size of the original. (For merge sort, both
a
and
b
are
2
,
but we shall see many divide-and-conquer algorithms in which
a
¤
b
.) It takes
time
T .n=b/
to solve one subproblem of size
n=b
, and so it takes time
aT .n=b/
to solve
a
of them. If we take
D.n/
time to divide the problem into subproblems
and
C.n/
time to combine the solutions to the subproblems into the solution to the
original problem, we get the recurrence
T .n/
D
(
‚.1/
if
n
c ;
aT .n=b/
C
D.n/
C
C.n/
otherwise
:
In Chapter 4, we shall see how to solve common recurrences of this form.

Download 4,84 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   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