- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Algorithms 國立清華大學資訊工程學系 Josephus Problem Flavius Josephus is a Jewish historian living in the 1st century. According to his account, he and his 40 comrade soldiers were trapped in a cave, surrounded by Romans. They chose suicide over capture and decided that they would form a circle and start killing one by skipping every two others. By luck, or maybe by the hand of God, Josephus and another man remained the last and gave up to the Romans. Outline The first algorithm Model, simulation, algorithm primitive The second algorithm Algorithm discovery, recursion The third algorithm Solving recursion, mathematical induction The central role of computer science Why study math? * * * * * * * * * * * * * * * * Guess the Solution f(n) = 2k+1 k = n – the first number in n’s group The first number in n’s group is 2m. 2m ? n 2m+1 How fast can you find m? (1) use “binary search” on the bit pattern of n Since n has log2(n) bits, it takes log2(log2(n)) steps. (2) use “log2” function and take its integer part It takes constant time only. (independent of n.) Verify the Solution If f(n)=2k+1, k=n–2m is the solution, it must satisfy the recursion How to prove it? Hint: using mathematical induction Comparison of 3 Algorithms Running time n 10 3 10 4 10 5 10 6 10 7 10 8 10 -8 10 -6 10 -4 10 -2 10 0 10 2 Algorithm 1 Algorithm 2 Algorithm 3 The Central Role of Computer Science Why study math? Algorithms Studied so Far In chap 1, binary and decimal conversion, 2’s complement calculation, data compression, error correction, encryption… In chap 2, we studied how to use computer to implement algorithms In homework 4, we have problems for pipeline, prefix sum (parallel algorithm), and virtual memory page replacement (online algorithm) In chap 3, we saw examples of using algorithms to help manage resources Virtual memory mapping, scheduling, concurrent processes execution, etc. In chap 4, we learned protocols (distributed, randomized algorithms) CSMA/CD, CSMA/CA, routing, handsha
您可能关注的文档
- 23. “神童”的秘诀.ppt
- 27、买木雕的少年-第一课时.PPT
- 28 丑小鸭.ppt
- 3.2 最大熵谱估计.ppt
- 3.2解一元一次方程.ppt
- 3讲第五节 水准测量成果计算.ppt-A.ppt
- 4 采蘑菇.ppt
- 4.1Extreme Values of Functions.ppt
- 4.明清皇权和中央集权制度的强化.ppt
- 4月10日营运部巡店门店整改反馈报告.ppt
- All-Pairs Shortest Paths (26.025).ppt
- Althea's world!!(^0^).ppt
- ang eng ing ong 胡勇.ppt
- Ans to Q5-Ch12.ppt
- Anti-Viral Vaccines.ppt
- Applied Thermodynamics应用热力学.ppt
- Aquarius Level-2 Product Content.ppt
- Architecture de Réseaux RedondantsTravaux Pratiques.ppt
- ARDS中西医综合治疗探索.ppt
- ARM及Thumb指令集(练习).ppt
文档评论(0)