最新春季 – 算法导论课程

 

最新春季 - 算法导论课程

分析

loop-invariant

• A technique to prove that an algorithm is correct. Identify a loop-invariant.

 

• Initialization: It is true prior to the first iteration of a loop.
• 初始化:循环的第一次迭代之前,为真
• Maintenance: If it is true before an iteration of the loop, it remains true before the next iteration.
• 保持:如果循坏的某次迭代之前 为真,那么下次迭代之前它仍为真
• Termination: when the loop terminates, the invariant givesus a useful property that shows that the algorithm is correct.
• 终止:在循环终止时,不变式为我们提供一个有用的性质,该性质有助于证明算法的正确性。

RAM

  • We shall assume a generic one-processor, random-access machine (RAM) model of computation.

    我们将假设一个通用的单处理器随机存取机(RAM)计算模型

 

-- Instructions are executed one after another, with no concurrent operations.
-- Each time, an instruction of a program is executed as an atom operation. An instruction includes arithmetic operations, logical operations, data movement and control operations.
-- Each such instruction takes a constant amount of time. 
-- RAM capacity is large enough.

- 指令一个接一个地执行,没有并行操作。
- 每次,程序指令都作为原子操作执行。 一条指令包括算术运算,逻辑运算,数据移动和控制操作。
- 每个这样的指令都需要一定的时间。 
- RAM容量足够大。
  • Under RAM model: count fundamental operations

    在RAM模式下:统计基本操作

  • RAM 计算T(n)

T(n) 时间复杂度计算(练题)

顺序 — 串行

选择 — if 、switch-case

循环 — 插入排序

递归 — 归并排序

递归树 Recursion Tree


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值