Algorithms For Dummies


Arranging and Searching Data



Download 7,18 Mb.
Pdf ko'rish
bet257/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   253   254   255   256   257   258   259   260   ...   651
Bog'liq
Algorithms

  Arranging and Searching Data 

     143


smaller value than lower-level branches and leaves. The effect is to keep the tree 

balanced and in a predictable order so that searching becomes extremely efficient. 

The cost is in keeping the tree balanced. The following sections describe how 

search trees and the heap work in detail.



Considering the need to search effectively

Of all the tasks that applications do, searching is the more time consuming and 

also the one required most. Even though adding data (and sorting it later) does 

require some amount of time, the benefit to creating and maintaining a dataset 

comes from using it to perform useful work, which means searching it for impor-

tant  information.  Consequently,  you  can  sometimes  get  by  with  less  efficient 

CRUD functionality and even a less-than-optimal sort routine, but searches must 

proceed as efficiently as possible. The only problem is that no one search performs 

every task with absolute efficiency, so you must weigh your options based on what 

you expect to do as part of the search routines.

Two  of  the  more  efficient  methods  of  searching  involve  the  use  of  the  binary 

search tree (BST) and binary heap. Both of the search techniques rely on a tree-

like structure to hold the keys used to access data elements. However, the arrange-

ment of the two methods is different, which is why one has advantages over the 

other when performing certain tasks. Figure 7-1 shows the arrangement for a BST.

Note how the keys follow an order in which lesser numbers appear to the left and 

greater numbers appear to the right. The root node contains a value that is in the 

middle of the range of keys, giving the BST an easily understood balanced approach to 

storing the keys. Contrast this arrangement to the binary heap shown in Figure 7-2.

FIGURE 7-1: 

The arrangement 

of keys when 

using a BST.




144


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   253   254   255   256   257   258   259   260   ...   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