离散数学——Algorithm and Recurrence
Algorithm
Big-O
Definition of Big-O
These are some frequently used Big-O estimates for some functions
There are rules for combination of Big-O
Definition of function type
Under this definition, polynomials are of the same type, but a polynomial and a exponential aren't
N, NP, NPC, NP Hard
P(polynomial)问题:能在多项式时间内解决的问题
NP(non-deterministic polynomial)问题:能在多项式时间内验证答案的问题
P属于NP,能在多项式时间内解决,一定能在多项式时间验证
NP complete: NP complete 属于 NP,即可以在多项式时间内验证,且所有NP问题都可以归约到NP complete,NP complete是NP中最难的问题,能解决NP complete的算法就能解决所有NP
NP hard: NP hard不一定能在多项式时间内验证,NP hard与NP有交集,交集就是NP complete,所有NP都能归约到NP hard
Input size
Recurrence
First-order linear recurrence
First-order linear recurrence: 形如
解决First-order linear recurrence function,一步步往回推找到规律即可,最后用base case来替代掉T(n)
Master Theorem
Linear homogeneous relation
Linear homogeneous relation is of the form:
The solution to is of the form:
Put the solutions of back to the linear homogeneous relation, and we get characteristic function
For characteristic function of degree 2, we have the following theorem
- When the function has 2 different roots
- When the function only has 1 root
Then put the condition we get on base case, then we can solve and
For characteristic function of more than 2 degree, we have the following theorem
Linear non-homogeneous recurrence relation
Linear non-homogeneous recurrence relation is of the form:
The solution to is of the form
we can get by ignoring the f(n) part, and use method in solving linear homogeneous recurrence relation
for , we assume , and now we ignore the part, and let to solve
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App