Get current working directory


How Selection Sort Works?



Download 0,84 Mb.
bet12/21
Sana21.04.2022
Hajmi0,84 Mb.
#569000
1   ...   8   9   10   11   12   13   14   15   ...   21
Bog'liq
notes2

How Selection Sort Works?


Consider the following depicted integer array as an example.

For the first position in the sorted list, the whole list is scanned sequentially. The first position where 20 is stored presently, we search the whole list and find that 15 is the lowest value.

So we replace 20 with 15. After one iteration 15, which happens to be the minimum value in the list, appears in the first position of the sorted list.

For the second position, where 23 is residing, we start scanning the rest of the list in a linear manner.

We find that 20 is the second lowest value in the list and it should appear in the second place. We swap these values.

After two iterations, the two least values are positioned at the beginning in a sorted manner.

Now, scan the rest of the list in a linear manner and check third smallest value in the list 21 and it stayed in the same position.

Let's scan the rest of the list in a linear manner and find fourth smallest value in the list that 23 and replace 25 with 23.

This is an end of an array, after sorting array the final output looks as below:

Advantages


  • Easy to implement

  • In-place sort (requires no additional storage space)

Disadvantages


  • Doesn’t scale well: O(n2)

This algorithm is called selection sort since it repeatedly selects the smallest element.

Let's implement Selection Sort algorithm using Java.

JDBC

1. What is JDBC?




Java Database Connectivity or JDBC API provides industry-standard and database-independent connectivity between the Java applications and relational database servers (relational databases, spreadsheets, and flat files).



To keep it simpleJDBC allows a Java application to connect to a relational database. The major databases are supported such as Oracle, Microsoft SQL Server, DB2 and many others.




Download 0,84 Mb.

Do'stlaringiz bilan baham:
1   ...   8   9   10   11   12   13   14   15   ...   21




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