Introduction to Algorithms, Third Edition



Download 4,84 Mb.
Pdf ko'rish
bet161/618
Sana07.04.2022
Hajmi4,84 Mb.
#534272
1   ...   157   158   159   160   161   162   163   164   ...   618
Bog'liq
Introduction-to-algorithms-3rd-edition

Problems
10-1
Comparisons among lists
For each of the four types of lists in the following table, what is the asymptotic
worst-case running time for each dynamic-set operation listed?
unsorted,
sorted,
unsorted,
sorted,
singly
singly
doubly
doubly
linked
linked
linked
linked
S
EARCH
.L; k/
I
NSERT
.L; x/
D
ELETE
.L; x/
S
UCCESSOR
.L; x/
P
REDECESSOR
.L; x/
M
INIMUM
.L/
M
AXIMUM
.L/


250
Chapter 10
Elementary Data Structures
10-2
Mergeable heaps using linked lists
A
mergeable heap
supports the following operations: M
AKE
-H
EAP
(which creates
an empty mergeable heap), I
NSERT
, M
INIMUM
, E
XTRACT
-M
IN
, and U
NION
.
1
Show how to implement mergeable heaps using linked lists in each of the following
cases. Try to make each operation as efficient as possible. Analyze the running
time of each operation in terms of the size of the dynamic set(s) being operated on.
a.
Lists are sorted.
b.
Lists are unsorted.
c.
Lists are unsorted, and dynamic sets to be merged are disjoint.
10-3
Searching a sorted compact list
Exercise 10.3-4 asked how we might maintain an
n
-element list compactly in the
first
n
positions of an array. We shall assume that all keys are distinct and that the
compact list is also sorted, that is,
key
Œi <
key
Œ
next
Œi 
for all
i
D
1; 2; : : : ; n
such
that
next
Œi 
¤
NIL
. We will also assume that we have a variable
L
that contains
the index of the first element on the list. Under these assumptions, you will show
that we can use the following randomized algorithm to search the list in
O.
p
n/
expected time.
C
OMPACT
-L
IST
-S
EARCH
.L; n; k/
1
i
D
L
2

Download 4,84 Mb.

Do'stlaringiz bilan baham:
1   ...   157   158   159   160   161   162   163   164   ...   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