November 19, 2009.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
November 19, 2009.ppt

Theory of Computation Lecture 19: Calculations on Strings IV November 19, 2009 Theory of Computation Lecture 19: Calculations on Strings IV * Numerical Representation of Strings Correspondingly, we define the following: For x ? N, let w be the string in ?* which represents x in base l. Let w’ be obtained from w by crossing out all of the symbols that belong to ? – A, so w’ ? A*. We write DOWNCHANGEn,l(x) for the number which w’ represents in base n. Example: DOWNCHANGE2,6(109) = 5 The representation of 109 in base 6 is s2s6s1. We cross out the s6 and get s2s1. In base 2, s2s1 represents the number 5. November 19, 2009 Theory of Computation Lecture 19: Calculations on Strings IV * Numerical Representation of Strings UPCHANGEn,l and DOWNCHANGEn,l are actually primitive recursive functions, but now we will just show that they are computable. This program computes UPCHANGEn,l: [A] IF X = 0 GOTO E Z ← LTENDn(X) // Z receives leftmost symbol X ← LTRUNCn(X) // removes this symbol from x Y ← l ? Y + Z // add to output GOTO A November 19, 2009 Theory of Computation Lecture 19: Calculations on Strings IV * Numerical Representation of Strings Let us look at the computation of UPCHANGE2,10(12) iteration by iteration (string s2s1s2): [A] IF X = 0 GOTO E Z ← LTENDn(X) X ← LTRUNCn(X) Y ← l ? Y + Z GOTO A 0. Z = 0, Y = 0, X = 12 Z = 2, Y = 2, X = 4 Z = 1, Y = 21, X = 2 Z = 2, Y = 212, X = 0 Result: 212 November 19, 2009 Theory of Computation Lecture 19: Calculations on Strings IV * Numerical Representation of Strings This program computes DOWNCHANGEn,l: [A] IF X = 0 GOTO E Z ← LTENDl(X) // Z receives leftmost symbol X ← LTRUNCl(X) // removes this symbol from x IF Z n GOTO A // check if we must cross out Z Y ← n ? Y + Z // if not, ad

文档评论(0)

zhaoxq + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档