Dab tsi yog qhov xwm txheej phem tshaj plaws ntawm kev ua npuas?

Cov txheej txheem:

Dab tsi yog qhov xwm txheej phem tshaj plaws ntawm kev ua npuas?
Dab tsi yog qhov xwm txheej phem tshaj plaws ntawm kev ua npuas?

Video: Dab tsi yog qhov xwm txheej phem tshaj plaws ntawm kev ua npuas?

Video: Dab tsi yog qhov xwm txheej phem tshaj plaws ntawm kev ua npuas?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Kaum ib hlis
Anonim

Npuas txheeb, qee zaum hu ua sinking sort, yog ib qho yooj yim sorting algorithm uas pheej rov ua cov kauj ruam los ntawm cov npe, sib piv cov khoom nyob ib sab thiab sib pauv lawv yog tias lawv nyob hauv qhov kev txiav txim tsis raug. Daim ntawv hla dhau yuav rov ua dua kom txog thaum cov npe tau txheeb.

Yuav ua li cas yog qhov kev txiav txim ntawm qhov nyuaj hauv npuas ua qhov phem tshaj?

Npuas Sort yog ib qho yooj yim-rau-ua, ruaj khov sorting algorithm nrog lub sij hawm complexity ntawm O(n²) nyob rau hauv nruab nrab thiab phem tshaj plaws - thiab O (n) nyob rau hauv qhov zoo tshaj plaws.

Vim li cas qhov xwm txheej phem tshaj plaws rau npuas hom N 2?

Qhov xwm txheej phem tshaj plaws rau kev ua npuas yog thaum qhov tsawg tshaj plaws ntawm cov npe yog qhov kawg . … Hauv qhov xwm txheej phem tshaj plaws no, nws siv n iterations ntawm n/2 swaps ces qhov kev txiav txim yog, dua, n2.

Vim li cas npuas thiaj li phem tshaj?

Qhov xwm txheej phem tshaj plaws rau kev ua npuas yog thaum daim ntawv teev cov khoom me tshaj plaws nyob rau hauv txoj haujlwm kawg… daim ntawv teev npe, lub ntsiab lus hais tias qhov kev xaiv yuav tsum tau ua kom muaj tus lej ntau dhau ntawm cov npe, uas yog n - 1.

Koj ua li cas xam cov ntaub ntawv zoo tshaj plaws ntawm kev ua npuas ncauj?

txhawm rau xam qhov nyuaj ntawm qhov ua npuas sib txawv, nws yog qhov tseem ceeb rau txiav txim siab pes tsawg qhov sib piv txhua lub voj ua haujlwm. Rau txhua lub ntsiab lus hauv cov array, cov khoom npuas ua n − 1 n-1 n−1 sib piv. Nyob rau hauv qhov loj O cim, ua npuas ncauj ua O (n) O (n) O (n) kev sib piv.

Pom zoo: