Qhov Sib txawv ntawm Cov Tsob Ntoo Ua tiav Binary thiab Tsob Ntoo Tsob Ntoo Tag Nrho

Qhov Sib txawv ntawm Cov Tsob Ntoo Ua tiav Binary thiab Tsob Ntoo Tsob Ntoo Tag Nrho
Qhov Sib txawv ntawm Cov Tsob Ntoo Ua tiav Binary thiab Tsob Ntoo Tsob Ntoo Tag Nrho

Video: Qhov Sib txawv ntawm Cov Tsob Ntoo Ua tiav Binary thiab Tsob Ntoo Tsob Ntoo Tag Nrho

Video: Qhov Sib txawv ntawm Cov Tsob Ntoo Ua tiav Binary thiab Tsob Ntoo Tsob Ntoo Tag Nrho
Video: qhov ncauj qhia tau neeg Tus YAM NTXWV thiab TXOJ HMOO 2024, Hlis ntuj nqeg
Anonim

Tshaj Binary Tsob Ntoo vs Full Binary Tsob Ntoo

Binary tsob ntoo yog tsob ntoo uas txhua tus ntawm muaj ib lossis ob tug me nyuam. Hauv ib tsob ntoo binary, ib lub pob tsis tuaj yeem muaj ntau tshaj ob tus menyuam. Hauv tsob ntoo binary, cov menyuam yaus hu ua "sab laug" thiab "txoj cai" cov menyuam yaus. Cov me nyuam nodes muaj cov ntaub ntawv hais txog lawv niam lawv txiv. Ib tsob ntoo ua tiav binary yog tsob ntoo binary uas txhua qib ntawm tsob ntoo binary tau sau tag nrho tsuas yog qib kawg. Nyob rau hauv cov theem tsis tau tiav, cov nodes txuas pib los ntawm sab laug-feem ntau txoj hauj lwm. Ib tsob ntoo binary tag nrho yog tsob ntoo uas txhua qhov ntawm tsob ntoo muaj ob tug me nyuam tsuas yog nplooj ntawm tsob ntoo.

Tus Tsob Ntoo Binary yog dab tsi?

Txhua binary tsob ntoo yog tsob ntoo binary uas txhua qhov ntawm tsob ntoo muaj xoom lossis ob tug menyuam. Hauv lwm lo lus, txhua qhov ntawm tsob ntoo tsuas yog nplooj muaj ob tug me nyuam. Daim duab 1 hauv qab no qhia txog ib tsob ntoo binary tag nrho. Nyob rau hauv ib tsob ntoo binary tag nrho, tus naj npawb ntawm cov nodes (n), tus naj npawb ntawm laves (l) thiab tus naj npawb ntawm sab hauv (i) muaj feem xyuam nrog txoj hauv kev tshwj xeeb xws li yog tias koj paub ib qho ntawm lawv koj tuaj yeem txiav txim siab lwm yam. tus nqi raws li hauv qab no:

1. Yog hais tias ib tsob ntoo binary tag nrho muaj kuv cov nodes:

– Tus lej ntawm nplooj l=i+1

– Tag nrho cov nodes n=2i+1

2. Yog tias tsob ntoo binary tag nrho muaj n nodes:

– Number of internal nodes i=(n-1)/2

– Tus lej ntawm nplooj l=(n+1)/2

3. Yog tias tsob ntoo binary tag nrho muaj l nplooj:

– Total Number of nodes n=2l-1

– Number of internal nodes i=l-1

Duab
Duab
Duab
Duab

Tus Tsob Ntoo Binary yog dab tsi?

Raws li pom hauv daim duab 2, tsob ntoo ua tiav binary yog tsob ntoo binary uas txhua theem ntawm tsob ntoo puv tag tsuas yog qib kawg. Tsis tas li ntawd, nyob rau theem kawg, cov nodes yuav tsum tau txuas nrog pib ntawm sab laug-feem ntau txoj hauj lwm. Ib tsob ntoo tiav binary ntawm qhov siab h txaus siab rau cov xwm txheej hauv qab no:

– Los ntawm lub hauv paus node, theem saum toj kawg nkaus theem sawv cev tag nrho binary tsob ntoo ntawm qhov siab h-1

– Ib lossis ntau qhov ntawm qib kawg yuav muaj 0 lossis 1 tus menyuam

– Yog tias a, b yog ob leeg nyob rau theem siab dua qib kawg, ces ib tug muaj me nyuam ntau dua b yog thiab tsuas yog ib tug nyob sab laug ntawm b

Dab tsi yog qhov txawv ntawm Tsob Ntoo Binary thiab Full Binary Tsob Ntoo?

Tau tiav binary ntoo thiab tag nrho binary ntoo muaj qhov sib txawv. Thaum ib tsob ntoo binary tag nrho yog ib tsob ntoo binary uas txhua lub node muaj pes tsawg los yog ob tug me nyuam, ib tsob ntoo binary tiav yog ib tsob ntoo binary uas txhua qib ntawm tsob ntoo binary tau sau tag nrho tsuas yog qib kawg. Qee cov ntaub ntawv tshwj xeeb xws li heaps yuav tsum ua kom tiav binary ntoo thaum lawv tsis tas yuav tsum tau ua tiav binary ntoo. Nyob rau hauv ib tsob ntoo binary tag nrho, yog tias koj paub tus naj npawb ntawm tag nrho cov nodes los yog tus naj npawb ntawm laves los yog tus naj npawb ntawm cov nodes sab hauv, koj tuaj yeem nrhiav tau ob qho yooj yim heev. Tab sis ib tsob ntoo binary tiav tsis muaj cov cuab yeej tshwj xeeb hais txog peb tus cwj pwm no.

Pom zoo: