联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> OS作业OS作业

日期:2024-03-24 05:01

CMPSC 465

Data Structures & Algorithms

Spring 2024

Worksheet 2

1. Growth Rate. Sort the following expressions from slowest to fastest growth rate. (You may assume all logarithms have base 2.)

2. Find run time. How long does the recursive multiplication algorithm (given below) take to multiply a non-negative n-bit number by a non-negative m-bit number? Justify your answer.

Algorithm 1 multiply(x,y)

Input: An n-bit integer x and an m-bit integer y, where x, y ≥ 0

Output: Their product x · y

if y = 0 then

   return 0

end if

z = multiply(x,?2/y?)

if y = even then

   return 2z

else

   return x+2z

end if

3. Computing Factorials. Consider the problem of computing N! = 1×2×··· ×N.

1. If N is a b-bit number, how many bits long is N! (Θ notation suffices)?

2. Consider the simple algorithm to compute N! that does the multiplication in sequence, 1×2×3×...×N. Analyze its running time.

4. Fibonacci growth. The Fibonacci numbers F0, F1, F2 ... are defined by the recurrence F0 = 0, F1 = 1, and Fn = Fn?1 + Fn?2. In this problem, we will confirm that this sequence grows exponentially fast and obtain some bounds on its growth.

(a) Use induction to prove that Fn ≥ 2 0.5n for n ≥ 6.

(b) Find a constant c > 0 such that Fn ≥ 2cn for all n ≥ 3. Show that your answer is correct.

(c) Find the maximum constant c > 0 for which Fn = ?(2cn).

版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp