Puas yog DFS greedy?
Puas yog DFS greedy?

Video: Puas yog DFS greedy?

Video: Puas yog DFS greedy?
Video: GREED, BETRAYAL & THE FRACTURING OF RPS 2024, Kaum ib hlis
Anonim

Breadth-thawj nrhiav tsis yog siab ntshaw algorithm ib-se. Ua pa-thawj kev tshawb nrhiav tsis tshem tawm cov kev xaiv, nws scans tag nrho cov duab yam tsis tau muab pov tseg uas tsis yog-lub zos siab tshaj ntawm cov nodes thiab los yog ib qho ntawm, thiab tsis txawm tias tseem ceeb nyob rau hauv txhua txoj kev uas muaj feem xyuam rau kev soj ntsuam muaj nuj nqi.

Tsis tas li ntawd, dab tsi yog greedy zoo tshaj plaws nrhiav thawj?

Zoo tshaj - thawj nrhiav yog a nrhiav algorithm uas tshawb txog ib daim duab los ntawm kev nthuav dav cov kev cog lus feem ntau xaiv raws li txoj cai. Hom tshwj xeeb ntawm no nrhiav hu ua greedy zoo tshaj plaws - thawj nrhiav los yog ntshiab heuristic nrhiav.

Ib yam li ntawd, DFS algorithm piv txwv yog dab tsi? Depth First Search (DFS) algorithm traverses a daim duab nyob rau hauv ib tug tob tob tsab ntawv tsa suab thiab siv ib pawg kom nco ntsoov kom tau lub vertex tom ntej no mus pib nrhiav, thaum kawg tuag tshwm sim nyob rau hauv tej iteration. Raws li hauv qhov piv txwv tau hais los saum no, DFS algorithm traverses ntawm S mus rau A rau D rau G rau E rau B ua ntej, ces mus rau F thiab kawg mus rau C.

Ib sab saum toj no, dab tsi yog kev nrhiav kev ntshaw hauv kev txawj ntse?

Hauv siab nrhiav , peb nthuav cov node ze tshaj rau lub hom phiaj node. Qhov "ze" yog kwv yees los ntawm ib tug heuristic h(x). Txo tus nqi ntawm h(x), ze dua yog qhov ntawm lub hom phiaj. Lub tswv yim: nthuav cov node ze tshaj plaws rau lub xeev lub hom phiaj, piv txwv li nthuav cov node nrog qis h tus nqi.

Puas yog lub hnub qub greedy?

A* zoo li Greedy Qhov zoo tshaj plaws-Thawj-Nrhiav nyob rau hauv uas nws siv tau ib tug heuristic coj nws tus kheej.

Pom zoo: