!!!Chapter 1 Introduction

1.2 Mathematics Review

Exponents

http://baike.baidu.com/view/5711140.htm

Logarithms

http://en.wikipedia.org/wiki/Logarithm

Series

arithmetic series 等差数列:

Sn=n(a1+an)/2

geometric series 等比数列:

Sn=a1(1-q^n)/(1-q)=(a1-an*q)/(1-q)

http://baike.baidu.com/view/39749.htm

Modular Arithmatic

A is congruent to B modulo N, written A ≡ B (mod N), if N divides A - B.

e.g.

81 ≡ 61 ≡ 1 (mod 10)

The P Word

The two most common ways of proving statements in data structure analysis are proof by induction(归纳) and proof by contradiction(反证).

Induction

1. proving a base case

2. assume k works and prove k + 1 will work

Contradiction

Assuming that the theorem is false and showing that this assumption implies that some known property is false.

1.3 Recursion

A function defined in terms of itself is called recursive.

F(x) = 2F(x-1) + X

C allows functions to be recursive:

int F(int X)
{
// handle base case
    if(X == 0)
        return 0;
    else
        return 2*F(x - 1) + X;
} 
Recursive calls will keep on being made until a base case is reached.

Fundamental rules of recursion:

1. Base case. You must always have some base cases, which can be solved without recursion.

2. Making progress. For the cases that are to be solved recursively, the recursive call must always be to a case that makes progress toward a base case.

3. Design rule. Assume that all the recursive calls work.

4. Compound interest rule. Never duplicate work by solving the same instance of a problem in separate recursive calls.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值