Dab tsi yog heap data structure Java?
Dab tsi yog heap data structure Java?

Video: Dab tsi yog heap data structure Java?

Video: Dab tsi yog heap data structure Java?
Video: #1 Data Structure and Algorithm Tutorial in Amharic | በአማርኛ 2024, Kaum ib hlis
Anonim

A pob yog ib tsob ntoo cov ntaub ntawv qauv nyob rau hauv uas tag nrho cov nodes ntawm tsob ntoo nyob rau hauv ib tug tshwj xeeb kev txiav txim. Piv txwv li, yog tus niam txiv ntawm, ces tus nqi ntawm ua raws li ib qho kev txiav txim tshwj xeeb nrog rau tus nqi ntawm thiab tib qhov kev txiav txim yuav ua raws li cov ntoo.

Hauv qhov xwm txheej no, dab tsi yog pob zeb hauv Java?

Cov pob yog qhov chaw khiav haujlwm cov ntaub ntawv los ntawm qhov chaw nco rau txhua chav kawm thiab arrays raug faib. Cov pob yog tsim los ntawm lub tshuab virtual pib. Heap cia rau cov khoom yog reclaimed los ntawm ib tug tsis siv neeg cia tswj system (lub npe hu ua ib tug khib nyiab collector); cov khoom yeej tsis tau hais meej meej.

Tsis tas li ntawd, binary tsob ntoo puas yog heap? A binary pob yog a pob 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 kom paub yog, dab tsi yog cov ntaub ntawv heap siv rau?

Heaps yog siv hauv ntau lub npe nrov algorithms xws li Dijkstra's algorithm rau nrhiav txoj hauv kev luv tshaj, pob sorting algorithm, siv qhov tseem ceeb queues, thiab lwm yam. Qhov tseem ceeb, pob yog cov cov ntaub ntawv qauv koj xav tau siv thaum koj xav kom nkag mus rau qhov siab tshaj plaws lossis yam tsawg kawg nkaus sai heev.

Puas yog Java muaj cov ntaub ntawv heap?

4 Teb. PriorityQueue siv a pob . Koj siv tau Java Priority Queue li a Heap . Min Heap : kom khaws cov min ib txwm nyob saum toj, yog li koj tuaj yeem nkag mus rau hauv O(1).

Pom zoo: