《算法导论》第一章~第五章 要点笔记

本文探讨了布尔运算中的短路特性,并解释了如何利用这一特性来优化代码执行过程。此外,还介绍了时间复杂度的概念及其对于评估算法效率的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

short circuiting

The boolean operators "and" and "or" are short circuiting. That is, when we evaluate the expression "x and y" we first evaluate x. If x evaluates to FALSE, then the entire expression cannot evaluate to TRUE, and so we do not evaluate y. If, on the other hand, x evaluates to TRUE, we must evaluate y to determine the value of the entire expression.

 

Short-circuiting operators allow us to write boolean expressions such as "x NIL and f[x] = y" without worrying about what happens when we try to evaluate f[x] when x is NIL.

 

 

random-access machine (RAM)

random-access machine (RAM) model of computation as our implementation technology and understand that our algorithms will be implemented as computer programs. In the RAM model, instructions are executed one after another, with no concurrent operations. In later chapters, however, we shall have occasion to investigate models for digital hardware.

 

 

循环

while(){}(){}多一步。

循环中,while语句的的()判断要比{}执行多走一步。For(){}循环同理。

 

 

时间复杂度

It is the rate of growth, or order of growth, of the running time that really interests us.”

也就是说,时间复杂度其实度量的对象是时间增长规模

 

关于 upper bound and lower bound,书中有图:

类比:时间复杂度与比较关系

f(n) = O(g(n))

a ≤ b,

f(n) = Ω(g(n))

a ≥ b,

f(n) = Θ(g(n))

a = b,

f(n) = o(g(n))

a < b,

f(n) = ω(g(n))

a > b.

 

 

几个翻译

uniform random permutation          均匀随机排列

indicator random variables               示性随机变量

 

 

两人同一天出生的概率

More intuitively, once bi is chosen, the probability that bj is chosen to be the same day is 1/n. Thus, the probability that i and j have the same birthday is the same as the probability that the birthday of one of them falls on a given day.

 

 

 文氏图表达的集合运算

 

 

 

 

Cartesian product笛卡尔积的定义

The Cartesian product of two sets A and B, denoted A × B, is the set of all ordered pairs such that the first element of the pair is an element of A and the second is an element of B. More formally,

A × B = {(a b) : a A and b B}.

For example, {a, b}×{a, b, c} = {(a, a), (a, b), (a, c), (b, a), (b, b), (b, c)}. When A and B are finite sets, the cardinality of their Cartesian product is |A×B|=|A|×|B|

The Cartesian product of n sets A1, A2,..., An is the set of n-tuples(n元组)

A1 × A2 × ··· × An = {(a1, a2,..., an) : ai Ai, i = 1, 2,..., n},

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值