Introduction to Algorithms, Third Edition


Asymptotic notation, functions, and running times



Download 4,84 Mb.
Pdf ko'rish
bet43/618
Sana07.04.2022
Hajmi4,84 Mb.
#534272
1   ...   39   40   41   42   43   44   45   46   ...   618
Bog'liq
Introduction-to-algorithms-3rd-edition

Asymptotic notation, functions, and running times
We will use asymptotic notation primarily to describe the running times of algo-
rithms, as when we wrote that insertion sort’s worst-case running time is
‚.n
2
/
.
Asymptotic notation actually applies to functions, however. Recall that we charac-
terized insertion sort’s worst-case running time as
an
2
C
bn
C
c
, for some constants
a
,
b
, and
c
. By writing that insertion sort’s running time is
‚.n
2
/
, we abstracted
away some details of this function. Because asymptotic notation applies to func-
tions, what we were writing as
‚.n
2
/
was the function
an
2
C
bn
C
c
, which in
that case happened to characterize the worst-case running time of insertion sort.
In this book, the functions to which we apply asymptotic notation will usually
characterize the running times of algorithms. But asymptotic notation can apply to
functions that characterize some other aspect of algorithms (the amount of space
they use, for example), or even to functions that have nothing whatsoever to do
with algorithms.
Even when we use asymptotic notation to apply to the running time of an al-
gorithm, we need to understand
which
running time we mean. Sometimes we are
interested in the worst-case running time. Often, however, we wish to characterize
the running time no matter what the input. In other words, we often wish to make
a blanket statement that covers all inputs, not just the worst case. We shall see
asymptotic notations that are well suited to characterizing running times no matter
what the input.

-notation
In Chapter 2, we found that the worst-case running time of insertion sort is
T .n/
D
‚.n
2
/
. Let us define what this notation means. For a given function
g.n/
,
we denote by
‚.g.n//
the
set of functions
‚.g.n//
D f
f .n/
W
there exist positive constants
c
1
,
c
2
, and
n
0
such that
0
c
1
g.n/
f .n/
c
2
g.n/
for all
n
n
0
g
:
1
1
Within set notation, a colon means “such that.”


3.1
Asymptotic notation
45
(b)
(c)
(a)
n
n
n
n
0
n
0
n
0
f .n/
D
‚.g.n//
f .n/
D
O.g.n//
f .n/
D
.g.n//
f .n/
f .n/
f .n/
cg.n/
cg.n/
c
1
g.n/
c
2
g.n/

Download 4,84 Mb.

Do'stlaringiz bilan baham:
1   ...   39   40   41   42   43   44   45   46   ...   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