预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共77页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

程序设计与算法基础(5)OutlineExternalsortingExternalMergesortExternalMergeSortFromabinarytoanm-waytreeFromabinarytoanm-waytreeInput5blocks.Totaltimeforamergepass=200tIO+100tIM.whilemorethanonetreeisleftTimeToMergeS1andS2node=theleafcontainingS;Inotherwords,thenumberofkeysinallnonrootnodesinaB*-treeofordermis(2m-1)/3km-1.mmod3=0=>onenodehasm–1keysandtheotherhasm–2.Merge20RunsUsing5-WayMergingif(node!=null)Thelengthofthelongestprefixcommonontwowordsplusone(foraleveltodiscriminatebetweenthewordswiththisprefix)plusone(forthelevelofleaves)miissentwiththeprobabilitiespi,whichsatisfySpi=1RunMergingMerge20RunsMergeR1andR2TimeToMergeR1andR2TimeForPass1(RS)TimeToMergeS1andS2TimeForPass2(ST)TimeForEachMergePassTotalRun-MergingTimeFactorsInOverallRunTimeImproveRunGenerationImproveRunMergingMerge20RunsUsing5-WayMergingI/OTimePerMergePassHuffmancodingMergerunswithdifferentsizesDefinitionofmergecostAnothermergeorderDatacompressionShannontheoryOptimalcodeDeleteakeyfromaleafnode,thenumberofkeysintheleafislessthanm/2-1AB-treeoforder4findaproperpositioninarraykeysforK;#ofnodes=1+m+m2+m3+…+mh-1=(mh–1)/(m–1).Splittwonodesintothree,notoneintotwoContinuethemergeprocessiftheparentunderflowsNumberofpasses=logk(numberofinitialruns)28*1016-1Eachnonrootandeachnonleafnodeholdsk-1keysandkpointerstosubtreeswherem/2kmAllnodesexcepttherootarerequiredtobeatleasttwo-thirdsfull.Red-BlackTreesEachis5blockslong.4-WaySearchTreeAprefixtreeWeneedaccessdatasequentiallyinafastermannerthanusinginordertraversalUseB+-treestoindexthedataSo,numberofblocksincreases.ExamplesofHuffmancodeEfficiencyofHuffmancodingTheimplementationofHuffmancodeAdaptiveHuffmancodingMultiwaytreeAVLTreesRed-BlackTreesConvertingbetweenanm-waytreeandabinarytreeConvertingfromanm-waytreetoabinarytreeConvertingfromabinarytreetoanm-waytreeM-waysearchtreeB-Trees4-WaySearchTreeSomespecialB-treesThebasicstructureforaB-treenodeCapacityOfm-WaySearchTreeCapacityOfm-WaySearchTreeSearchinginaB-treeInsertakey(1)Insertakey(2)Insertakey(3)Insertakey(3c