北京邮电大学计算机学院--离散数学-11.2-trees.ppt

上传人:99****p 文档编号:1584807 上传时间:2019-03-06 格式:PPT 页数:34 大小:785.50KB
下载 相关 举报
北京邮电大学计算机学院--离散数学-11.2-trees.ppt_第1页
第1页 / 共34页
北京邮电大学计算机学院--离散数学-11.2-trees.ppt_第2页
第2页 / 共34页
北京邮电大学计算机学院--离散数学-11.2-trees.ppt_第3页
第3页 / 共34页
北京邮电大学计算机学院--离散数学-11.2-trees.ppt_第4页
第4页 / 共34页
北京邮电大学计算机学院--离散数学-11.2-trees.ppt_第5页
第5页 / 共34页
点击查看更多>>
资源描述

1、1* College of Computer Science return “Done” endelse if v = x return “Already present”else if x vreturn insert(rightSubtreeT, x)5* College of Computer Science & Technology, BUPTDecision Trees n A decision tree represents a decision-making process.n Each possible “decision point” or situation is repr

2、esented by a node.n Each possible choice that could be made at that decision point is represented by an edge to a child node.n In the extended decision trees used in decision analysis, we also include nodes that represent random events and their outcomes.6* College of Computer Science & Technology,

3、BUPTCoin-Weighing Problemn Imagine you have 8 coins, oneof which is a lighter counterfeit, and a free-beam balance.n No scale of weight markings is required for this problem!n How many weighings are needed to guarantee that the counterfeit coin will be found?7* College of Computer Science & Technolo

4、gy, BUPTAs a Decision-Tree Problemn In each situation, we pick two disjoint and equal-size subsets of coins to put on the scale.The balance then“decides” whether to tip left, tip right, or stay balanced.A given sequence ofweighings thus yieldsa decision tree withbranching factor 3.8* College of Comp

5、uter Science & Technology, BUPTApplying the Tree Height Theoremn The decision tree must have at least 8 leaf nodes, since there are 8 possible outcomes.n In terms of which coin is the counterfeit one.n Recall the tree-height theorem, hlogm.n Thus the decision tree must have heighth log38 = 1.893 = 2

6、.n Lets see if we solve the problem with only 2 weighings9* College of Computer Science & Technology, BUPTGeneral Solution Strategyn The problem is an example of searching for 1 unique particular item, from among a list of n otherwise identical items. n Somewhat analogous to the adage of “searching

7、for a needle in haystack.”n Armed with our balance, we can attack the problem using a divide-and-conquer strategy, like whats done in binary search.n We want to narrow down the set of possible locations where the desired item (coin) could be found down from n to just 1, in a logarithmic fashion.n Ea

8、ch weighing has 3 possible outcomes.n Thus, we should use it to partition the search space into 3 pieces that are as close to equal-sized as possible.n This strategy will lead to the minimum possible worst-case number of weighings required.10* College of Computer Science & Technology, BUPTGeneral Ba

9、lance Strategyn On each step, put n/3 of the n coins to be searched on each side of the scale.n If the scale tips to the left, then:n The lightweight fake is in the right set of n/3 n/3 coins.n If the scale tips to the right, then:n The lightweight fake is in the left set of n/3 n/3 coins.n If the scale stays balanced, then:n The fake is in the remaining set of n 2n/3 n/3 coins that were not weighed!n Except if n mod 3 = 1 then we can do a little better by weighing n/3 of the coins on each side.You can prove that this strategy always leads to a balanced 3-ary tree.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 课件讲义

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。