Algorithms For Dummies


Arranging and Searching Data



Download 7,18 Mb.
Pdf ko'rish
bet254/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   250   251   252   253   254   255   256   257   ...   651
Bog'liq
Algorithms

  Arranging and Searching Data 

     141


    while True:

        while lIndex <= rIndex and data[lIndex] <= pivot:

            lIndex 

+= 1


        while rIndex >= lIndex and data[rIndex] >= pivot:

            rIndex -= 1

        if rIndex <= lIndex:

            break

        data[lIndex], data[rIndex] = \

            data[rIndex], data[lIndex]

        print(data)

  

    data[left], data[rIndex] = data[rIndex], data[left]



    print(data)

    return rIndex



UNDERSTANDING QUICKSORT WORST-

CASE PERFORMANCE

Quicksort seldom incurs the worst-case sort time. However, even modified versions 

of the Quicksort can have a worst-case sort time of O(n

2

) when one of these events 



occurs:

• 

The dataset is already sorted in the desired order.



• 

The dataset is sorted in reverse order.



• 

All the elements in the dataset are the same.

All these problems occur because of the pivot point that a less intelligent sort function 

uses. Fortunately, using the right programming technique can mitigate these problems 

by defining something other than the leftmost or rightmost index as the pivot point. The 

techniques that modern Quicksort versions rely on include:




Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   250   251   252   253   254   255   256   257   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
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