ComputersProgramming

Sorting algorithms raws li lawv muaj

Qhov yog qhov kev kho ntawm cov khoom nyob rau hauv ib tug txiav txim, piv txwv li, nyob rau hauv ascending los yog nqis kev txiav txim. Nyob rau hauv dav dav, lub ordering hais - feem ntau cov ntaub ntawv manipulation los pab txhawb ntxiv mus nrhiav tus ntaub ntawv tsim nyog. Qhov no lom zem ntau txog ntau yam database tswj systems. Sorting algorithms muaj nyob rau hauv loj tus xov tooj ntawm no taw tes nyob rau hauv lub sij hawm, txawm tias lawv muaj zoo sib xws nta (theem): piv thiab permutation ntawm lub ntsiab nyob rau hauv officers li ntev raws li lub ib theem zuj zus yuav tsis tau yuam kom them.

Sorting algorithms yuav txwv kom muab zais rau hauv sab hauv thiab sab nraud. Cov yav tas los yog yus muaj los ntawm qhov tseeb hais tias tag nrho cov ntsiab yuav tsum tau txheeb yog muab tso rau hauv lub cim xeeb thiab tej zaum yuav tau txais random nkag tau mus rau ib yam ntawm lawv. Cov yav tas yuav ua hauj lwm nrog cov ntaub ntawv muab tso nyob rau hauv cov sab nraud nco (ib cov ntaub ntawv). Mus saib tau tej ntsiab tau muab los siv sequentially.

Lub nyiam tsi khoom thaum lawv muaj nyob rau hauv cov qauv ntawm cov ib tug ib-seem array. Txhua xws yam khoom muaj ib tug naj npawb, thiab chaw nyob mus rau lub array caij yuav siv sij hawm qhov chaw nyob rau hauv lub Performance index. sorting algorithms nyob rau hauv cov ntaub ntawv no yog cov feem ntau yooj yim thiab straightforward siv.

Xav txog cov internal sorting algorithm descending npuas txoj kev thiab nws paub version, ib tug txawv lub sij hawm siv rau sorting. Tsi yog npuas ua tau muaj ntau lub npe. Nws tseem hu ua ib tug linear sorting txoj kev los pauv sorting xaiv. Tab sis, txawm li cas los, nws tsis yog nyob rau hauv lub title. Yog vim li cas yog ib tug npuas? Ib zaug nyob rau hauv dej, huab cua npuas yuav pop li, raws li nws yog yooj yim. Piv txwv li, yog tias koj txheeb los ntawm ascending rau sab saum toj yuav tsum tau yam tsawg kawg ntawm lub ntsiab.

Xav txog ib tug thawj embodiment ntawm lub sorting algorithm npuas los ntawm cov array. Lus algorithm array sorting, muaj mas qhia tau thiab muaj N ntsiab, raws li nram no:

1. Muab rau qhov chaw ntawm lub thawj lub caij (mas [1]) qhov loj tshaj plaws lub caij ntawm lub array. Ua li no, peb yuav sib piv nws puv tag nrho cov seem ntsiab (mas [2], mas [3] ... mas [N]). Yog hais tias koj nrhiav tau hais tias ib yam ntawm cov lwm yam hais ntau tshaj mas [1], nws yuav tsum tau mus sib puav lawv (ntawm ib tug ntxiv nce mus nce los buf).

2. Los ntawm xa los ntawm kev saib xyuas mas lub caij [1] thiab rov qab ua cov kauj ruam 1 mus mas caij [2].

3. Cov kauj ruam rov rau tag nrho cov ntsiab tsuas yog lub xeem.

Ua raws li cov algorithm npuas tsi Pascal programming:

Hais txog qhov kev xaiv thib ob (cov advanced txoj kev ntawm lub npuas) koj yuav hais tias qhov no algorithm quicksort. Yog li ntawd, yog koj sim siv nws los txheeb lub array yog twb sorted, lub algorithm finishes nws ua hauj lwm tom qab cov thawj pass ntawm lub array ntsiab. Qhov no txhais tau tias peb yuav tsis nkim chaw muab kev pab thiab xam lub sij hawm nyob rau hauv meaningless sib piv ntsiab.

Ntawm no yog cov kev siv ntawm sorting algorithm rau lub Pascal programming lus:

Yog li ntawd, sorting algorithms yog ib tug txhais tau tias ntawm Workers ntaub ntawv sequences. Thaum xaiv ib lub algorithm yuav tsum coj mus rau hauv tus account tus nqi nyob rau hauv cov nqe lus ntawm lub sij hawm thiab chaw muab kev pab.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 hmn.unansea.com. Theme powered by WordPress.