Puas yog binary tsob ntoo heap?
Puas yog binary tsob ntoo heap?

Video: Puas yog binary tsob ntoo heap?

Video: Puas yog binary tsob ntoo heap?
Video: Трек Lucid Dreaming Sleep (8-часовой трек цикла сна) с бинауральными ритмами и изохронными тонами 2024, Kaum ib hlis
Anonim

A binary pob yog ua tiav tsob ntoo binary uas txaus siab rau pob xaj khoom. cov max- pob Cov cuab yeej: tus nqi ntawm txhua qhov ntawm qhov tsawg dua lossis sib npaug ntawm tus nqi ntawm nws niam nws txiv, nrog rau qhov siab tshaj plaws-tus nqi ntawm lub hauv paus.

Raws li, heap yog ib tsob ntoo binary?

A binary pob yog ua tiav tsob ntoo binary uas txaus siab rau pob xaj khoom. lub min- pob cov cuab yeej: tus nqi ntawm txhua qhov node ntau dua lossis sib npaug ntawm tus nqi ntawm nws niam nws txiv, nrog rau qhov tsawg kawg nkaus-tus nqi ntawm lub hauv paus.

Tsis tas li ntawd, binary heap data structure yog dab tsi? A binary pob yog a heap cov ntaub ntawv qauv uas siv daim ntawv ntawm a tsob ntoo binary . Binary heaps yog ib txoj hauv kev los ua cov txheej txheem ua ntej. Heap Cov cuab yeej: tus yuam sij khaws cia nyob rau hauv txhua lub node yog ntau dua lossis sib npaug rau (≧) lossis tsawg dua lossis sib npaug rau (≦) cov yuam sij hauv cov node cov menyuam, raws li qee qhov kev txiav txim tag nrho.

Kuj Paub, qhov txawv ntawm heap thiab binary ntoo yog dab tsi?

Heap tsuas yog lav tias cov ntsiab lus ntawm qib siab dua yog ntau dua (rau max- pob ) los yog me me (rau min- pob ) tshaj cov ntsiab lus ntawm qib qis, qhov BST lav kev txiav txim (los ntawm "sab laug" rau "txoj cai"). Yog tias koj xav txheeb cov ntsiab lus, mus nrog BST. Heap yog qhov zoo dua ntawm findMin/findMax (O(1)), thaum BST zoo ntawm txhua qhov pom (O(logN)).

Heap nco yog dab tsi?

Cov pob yog a nco siv los ntawm cov lus programming los khaws cov hloov pauv thoob ntiaj teb. Los ntawm lub neej ntawd, txhua qhov hloov pauv thoob ntiaj teb tau khaws cia rau hauv heap nco qhov chaw. Nws txhawb Dynamic nco faib. Cov pob yog tsis tswj tau rau koj thiab tsis yog raws li nruj tswj hwm los ntawm CPU. Nws zoo li thaj tsam dawb-floating ntawm nco.

Pom zoo: