资料结构小考解答.ppt

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

資料結構 第一次小考解答 1.(16%)Determine whether the following statements are correct 以定義判斷 10nlogn+12n2+8n ≤ C(n2) 存在 C=22, n0 = 2 當n ≧n0 時, 10nlogn+12n2+8n ≤ C(n2)成立 本題為True 找等式左邊成長速度最快的是不是3n 15n3n常數乘法可以忽略 只討論n3n n3n比3n成長速度還快 ,所以本題為False 找等式左邊成長速度最快的是不是 nlogn 5n2常數乘法可以忽略 只討論n2 n2比nlogn成長速度還快 ,所以本題為False 以定義判斷 8n5+3n≧C(2n) 存在 C=1, n0 = 1 當n ≧n0 時, 8n5+3n≧C(2n)成立 本題為True 2.(10%)Compute the failure function for pattern “aabaababaa” failure function初始值為-1 與前一項『 failure function 值+1』項做比較 ?相等 :failure function = 前一項『 failure function 值+1』 ?不相等: failure function= -1 3.(10%) Please write an algorithm to calculate the result of a postfix expression. Algorithm定義 1.一定要有Input 2.每一指令清楚說明要做什麼 3.在有限的步驟結束 本題解答 由左到右讀取 post expression 3分 當讀取到數字則push進stack 3分 當讀取到運算符號,pop出兩個數字並做運算,再把結果push進stack 4分 4.(10%) Please analyze the time complexity (in terms of q()) of the following program. ? int F(int n) { int x=n; +1 if (n=1) +1 return n; +1 else +1 {for (int i=0; i n; i++) +( n+1 ) x=x+i; +n return x; }} +1 5.If following declaration is used to implement a “circular queue”, please answer the following questions. int queue[MAX_QUEUE_SIZE]; int front,rear; a.(4%) Initially, what values will you assign to front and rear? Front = Rear = 0 各2分? b.(10%) When inserting and deleting, please state the equations that you use to change the values of front and rear. 寫出insert和delete時 rear 跟front的通式 為了防止超出Queue的範圍 需mod 最大容量 Insert: rear = (rear + 1) % [MAX_QUEUE_SIZE]; 5分 delete: front = (front + 1) % [MAX_QUEUE_SIZE]; 5分 c.(6%) How do you judge the queue is

文档评论(0)

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

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

版权声明书
用户编号:8140007116000003

1亿VIP精品文档

相关文档