Cov txheej txheem:

Koj pom qhov nruab nrab ntawm kev tshawb nrhiav binary li cas?
Koj pom qhov nruab nrab ntawm kev tshawb nrhiav binary li cas?

Video: Koj pom qhov nruab nrab ntawm kev tshawb nrhiav binary li cas?

Video: Koj pom qhov nruab nrab ntawm kev tshawb nrhiav binary li cas?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Kaum ib hlis
Anonim

Muab ib tug sorted array, peb nrhiav tau nruab nrab -feem ntau lub caij thiab xyuas lub caij nrog tus yuam sij. Yog tias nruab nrab -feem ntau yog sib npaug rau qhov tseem ceeb, peb tau pom tus yuam sij. Yog tias nruab nrab -feem ntau lub ntsiab yog ntau dua qhov tseem ceeb, peb nrhiav nyob rau sab laug ib nrab ntawm cov nruab nrab -feem ntau yam, lwm yam peb nrhiav ntawm sab xis ib nrab.

Ib yam li ntawd, tib neeg nug, koj nrhiav binary nrhiav li cas?

Nrhiav Binary : Nrhiav ib tug txheeb array los ntawm rov faib cov nrhiav ntu ntu hauv ib nrab. Pib nrog ib ntus npog tag nrho cov array. Yog tus nqi ntawm cov nrhiav qhov tseem ceeb yog tsawg tshaj li qhov khoom nyob rau hauv nruab nrab ntawm lub caij nyoog, nqaim lub sij hawm mus rau lub qis ib nrab. Txwv tsis pub nqaim nws mus rau sab sauv ib nrab.

Ib yam li ntawd, qhov loj O ntawm kev tshawb nrhiav binary yog dab tsi? Binary nrhiav yog qhov tseeb a nrhiav kev ua haujlwm ntawm kev sib npaug BST ( binary nrhiav tsob ntoo). Xws li ib nrhiav muaj lub sij hawm complexity ntawm O (log n). Saib, koj cov array sorted tej zaum yuav raug saib raws li qhov tob-thawj nrhiav nyob rau hauv-kev txiav txim serialization ntawm ib tug balanced BST. Ntawd yog, recursively ua cov hauv qab no (pib nrog lub hauv paus):

Kuj paub, dab tsi yog 7 kauj ruam ntawm kev tshawb nrhiav binary?

Binary Nrhiav Algorithm

  • Kauj ruam 1 - Nyeem qhov tshawb nrhiav los ntawm tus neeg siv.
  • Kauj Ruam 2 - Nrhiav cov khoom nruab nrab hauv daim ntawv teev npe.
  • Kauj Ruam 3 - Sib piv cov khoom tshawb nrhiav nrog cov khoom nruab nrab hauv cov npe txheeb.
  • Kauj ruam 4 - Yog hais tias ob qho tib si sib phim, ces tso saib "Muab cov khoom pom !!!" thiab xaus qhov haujlwm.

Kev tshawb nrhiav binary ua haujlwm li cas?

Binary nrhiav yog ib qho algorithm zoo rau kev nrhiav ib yam khoom los ntawm cov npe txheeb xyuas cov khoom. Nws ua haujlwm los ntawm kev rov faib ua ib nrab ntawm cov npe uas ua tau muaj cov khoom, kom txog rau thaum koj tau txo qis qhov chaw ua tau rau ib qho xwb.

Pom zoo: