Source code online books for professionals by professionals



Download 4,67 Mb.
Pdf ko'rish
bet245/266
Sana31.12.2021
Hajmi4,67 Mb.
#213682
1   ...   241   242   243   244   245   246   247   248   ...   266
Bog'liq
2 5296731884800181221

Randomized select. Finds the median, or, in general, the kth order statistic (the kth smallest element). Works sort of 
like “half a quicksort.” It chooses a pivot element at random (or arbitrarily) and partitions the other elements to the left 
(smaller elements) or right (greater elements) of the pivot. The search then continues in the right portion, more or less 
like binary search. Perfect bisection is not guaranteed, but the expected running time is still linear. (See Listing 6-3.)
Select. The rather unrealistic, but guaranteed linear, sibling of randomized select. It works as follows: Divide the 
sequence into groups of five. Find the median in each using insertion sort. Find the median of these medians 
recursively, using select. Use this median of medians as a pivot and partition the elements. Now run select on the 
proper half. In other words, it’s similar to randomized select—the difference is that it can guarantee that a certain 
percentage will end up on either side of the pivot, avoiding the totally unbalanced case. Not really an algorithm you’re 
likely to use in practice, but it’s important to know about. (See Chapter 6.)
Selection sort. A simple sorting algorithm with quadratic running time. Very similar to insertion sort, but instead of 
repeatedly inserting the next element into the sorted section, you repeatedly find (that is, select) the largest element in 
the unsorted region (and swap it with the last unsorted element). (See Listing 4-4.)
Timsort. A super-duper in-place sorting algorithm based on mergesort. Without any explicit conditions for handling 
special cases, it is able to take into account partially sorted sequences, including segments that are sorted in reverse, 
and can therefore sort many real-world sequences faster than what would seem possible. The implementation in 
list.sort and sorted is also really fast, so if you need to sort something, that’s what you should use. (See the “Black 
Box” sidebar on timsort in Chapter 6.)

Download 4,67 Mb.

Do'stlaringiz bilan baham:
1   ...   241   242   243   244   245   246   247   248   ...   266




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