Cov txheej txheem:

Lub sij hawm complexity nyob rau hauv cov ntaub ntawv qauv yog dab tsi?
Lub sij hawm complexity nyob rau hauv cov ntaub ntawv qauv yog dab tsi?

Video: Lub sij hawm complexity nyob rau hauv cov ntaub ntawv qauv yog dab tsi?

Video: Lub sij hawm complexity nyob rau hauv cov ntaub ntawv qauv yog dab tsi?
Video: nkauj ntseeg hnov hai tia nej lub teb chaws ko nom tswv tsi pub pe hawm puas yog ntxawm yaj 2024, Hlis ntuj nqeg
Anonim

Lub sijhawm nyuaj ntawm ib qho algorithm quantifies tus nqi ntawm sij hawm coj los ntawm ib qho algorithm los khiav raws li kev ua haujlwm ntawm qhov ntev ntawm cov tswv yim. Ib yam li ntawd, Space nyuaj ntawm ib qho algorithm quantifies tus nqi ntawm qhov chaw los yog lub cim xeeb coj los ntawm ib tug algorithm los khiav raws li ib tug muaj nuj nqi ntawm qhov ntev ntawm cov tswv yim.

Kuj paub yog, Lub Sijhawm complexity txhais li cas?

Hauv computer science, lub lub sij hawm complexity yog lub computational complexity uas piav txog tus nqi ntawm sij hawm nws yuav siv sij hawm los khiav ib algorithm. Yog li, tus nqi ntawm sij hawm coj thiab tus naj npawb ntawm cov haujlwm theem pib ua los ntawm algorithm yog coj mus rau qhov sib txawv ntawm qhov feem ntau qhov tsis tu ncua.

Tsis tas li ntawd, lub sij hawm complexity xam tau li cas? Yog li peb tuaj yeem sib faib lossis faib los ntawm qhov xwm txheej tas mus li kom tau mus rau qhov kev qhia yooj yim tshaj plaws. Yog li 2N tsuas yog N. Qhov feem ntau metric rau xam lub sij hawm complexity yog Big O notation. Qhov no tshem tawm tag nrho cov yam tsis tu ncua kom cov khiav sij hawm tuaj yeem kwv yees nyob rau hauv kev sib raug zoo rau N raws li N mus txog infinity.

Kuj paub, hom kev sib txawv ntawm lub sijhawm nyuaj yog dab tsi?

Muaj ntau hom kev sib txawv ntawm lub sijhawm, yog li cia peb tshawb xyuas qhov yooj yim tshaj plaws

  • Lub sij hawm tsis tu ncua: O(1)
  • Linear Sijhawm Complexity: O(n)
  • Lub Sijhawm Logarithmic Complexity: O (log n)
  • Lub Sij Hawm Quadratic Complexity: O (n²)
  • Exponential lub sij hawm Complexity: O(2^n)

Yuav ua li cas yog lub sij hawm complexity ntawm ib tug algorithm piav nrog piv txwv?

Nkag siab Notations of Lub sij hawm nyuaj nrog Piv txwv Nws qhia qhov siab tshaj plaws yuav tsum tau los ntawm ib qho algorithm rau tag nrho cov input nqi. Nws sawv cev qhov xwm txheej phem tshaj plaws ntawm ib qho algorithm lub sij hawm complexity . Omega (qhia) yog cov txheej txheem ntawm kev ua haujlwm uas loj hlob sai dua lossis ntawm tib tus nqi raws li kev qhia.

Pom zoo: