欢迎来到天天文库
浏览记录
ID:14885001
大小:27.48 KB
页数:34页
时间:2018-07-30
《搜索算法之深度优先搜索(depth first search of search algorithm)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、搜索算法之深度优先搜索(Depthfirstsearchofsearchalgorithm)Icarefullycollateddocuments,documentsfromthenetworkIonlycollectandsortoutIfthereisanymistakePleasecheckityourself!Depthfirstsearchofsearchalgorithm[algorithmanalysis]ProgramminghasreallycometothepointnowLearn
2、fromhereYouknowwhatisbroadandprofoundTodaywearegoingtoeatthishoeiscalledthedepthfirstsearchmethodFirstofall,let'simagineamouseInamazeofsufferingoppressionRatsgoinattheentranceIt'scomingfromtheexitHowtogetthemouse?Ofcourse,isthis:ifamousemetstraightJustgo
3、straightaheadIfyouencounteraforkChooseoneofthemandcontinuetogodownIfyourunintoadeadendBacktothenearestforkChooseanotherroadandgoonIfyoumeetanexitTheendofthemouse'sjourneyisoverThebasicprincipleofdepthfirstsearchisthis:goaheadwiththesearchundercertaincond
4、itionsIfyoufailintheprocess(likeadeadmouse),gobackandchooseanotherpathtocontinuesearchingUntilthetargetisfoundImplementationofthisalgorithmWeneedtouseanotherbigtoolofprogrammingrecursionRecursionisaveryabstractconceptButineverydaylifeWecanstillseeitTaket
5、womirrorsFacethemfacetofaceWhatwillyousee?You'llseecountlessmirrorsinthemirror?What'sgoingon?AmirrorhastheimageofBmirrorBmirrorhastheimageofAmirrorTheimageofAmirroristhetrueportraitureofAmirroritselfThatistosay,theimageoftheAmirrorincludestheAmirrorAndth
6、eBmirrorintheAmirror......tiredAnnoyingandtonguetwisterIt'snoteasytounderstandInsteadofcomputerlanguage,AcallsBAndBcallsAagainSoindirectAcallstheAitselfThisimplementsarepetitivefunctionAnotherexampleisthattherewasamountaininthepastThereisatempleinthemoun
7、tainsThereisanoldmonkinthetempleTheoldmonkistellingastoryWhatdoyoumean?TherewasamountaininthepastThereisatempleinthemountainsThereisanoldmonkinthetempleTheoldmonkistellingastoryWhatdoyoumean?TherewasamountaininthepastThereisatempleinthemountainsThereisan
8、oldmonkinthetempleTheoldmonkistellingastoryWhatdoyoumean?Speaking:............GoodheavensThisisnottheendoftheworldThestorytheoldmonktellsisactuallythestorybeforeThisconstantlycallstheprogramitselfRecursionisformedWhatifone
此文档下载收益归作者所有