【精品数据结构】Binary and other trees.ppt

【精品数据结构】Binary and other trees.ppt

ID:50934416

大小:180.00 KB

页数:73页

时间:2020-03-16

【精品数据结构】Binary and other trees.ppt_第1页
【精品数据结构】Binary and other trees.ppt_第2页
【精品数据结构】Binary and other trees.ppt_第3页
【精品数据结构】Binary and other trees.ppt_第4页
【精品数据结构】Binary and other trees.ppt_第5页
资源描述:

《【精品数据结构】Binary and other trees.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Chapter8BinaryandothertreesTwokindsofdatastructureLinear:list,stack,queue,stringNon-linear:tree,graph8.1Tree1.Definition:AtreeTisafinitenonemptysetofelements.Oneoftheseelementsiscalledtheroot,andtheremainingelements(ifany)arepartitionedintotreeswhicharecalledthesubtreesofT.8.1TreeexampleABCDEFGHIJK

2、LM8.1Tree2.TerminologyDegreeofanelememts:thenumberofchildrenithas.Degreeofatree:themaximumofitselementdegreesLeaf:elementwhosedegreeis0Branch:elementwhosedegreeisnot08.1TreeLevel:thelevelofrootis1thelevelofanelement=thelevelofitsparent+1Depthofatree:themaximumlevelofitselements8.2BinaryTrees1.Defin

3、ition:Abinarytreetisafinite(possiblyempty)collectionofelements.Whenthebinarytreeisnotempty:IthasarootelementTheremainingelements(ifany)arepartitionedintotwobinarytrees,whicharecalledtheleftandrightsubtreesoft.8.2BinaryTrees2.Theessentialdifferencesbetweenabinarytreeandatreeare:1)Abinarytreecanbeemp

4、ty,whereasatreecannot.2)Eachelementinabinarytreehasexactlytwosubtrees(oneorbothofthesesubtreesmaybeempty).Eachelementinatreecanhaveanynumberofsubtrees.8.2BinaryTrees3)Thesubtreesofeachelementinabinarytreeareordered.Thatis,wedistinguishbetweentheleftandtherightsubtrees.Thesubtreesinatreeareunordered

5、.8.2BinaryTreesExampleofabinarytree+*/abcd8.3PropertiesofbinarytreesProperty1.Thedrawingofeverybinarytreewithnelements,n>0,hasexactlyn-1edges.Property2.Thenumberofelementsatleveliisatmost2i-1(i>=1).8.3PropertiesofbinarytreesProperty3.Abinarytreeofheighth,h>=0,hasatleasthandatmost2h–1elementsinit.pr

6、oofofproperty3:2i-1=20+21+……+2h-1=1*(1-2h)/(1-2)=2h–1i-1h8.3PropertiesofbinarytreesProperty4.Theheightofabinarytreethatcontainsn,n>=0,elementisatmostnandatleastlog2(n+1)proof:Sincetheremustbeatleastoneelementateachlevel,theheightcannotexceedn.Fromproperty3,weknown<=2h-1,so,h>=log2(n+1),sincehisa

7、ninteger,wegeth>=log2(n+1)8.3PropertiesofbinarytreesProperty5.Ifnumberofleavesisn0,andthenumberofthe2degreeelementsisn2,thenn0=n2+1.8.3PropertiesofbinarytreesDefinitionofafullbinarytree:Abinarytreeofheigh

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。