算法学习之“Big Oh Notation”

大O记法是描述算法渐进复杂度的工具,用于比较算法在问题规模n较大时的增长趋势。它由P. Bachmann在1892年发明。记法中的三个关键元素是起始点n0、倍数c和基准函数。常见的基准函数包括对数函数和线性函数。大O记法具有和、积的数学特性,并且在多项式情况下,通常忽略低阶项和系数。紧致的大O边界是寻找最精确的渐进界,常去除非主导项和常数系数,如将O(n^2+100)简化为O(n^2),O(10n)简化为O(n)。

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

一、Asymptotic analysis

Suppose we are considering two algorithms, A and B, for solving a given problem. Furthermore, let us say that we have done a careful analysis of the running times of each of the algorithms and determined them to be tex2html_wrap_inline59029 and tex2html_wrap_inline59031, respectively, where n is a measure of the problem size. Then it should be a fairly simple matter to compare the two functions tex2html_wrap_inline59029 and tex2html_wrap_inline59031 to determine which algorithm is the best!

这段话的意识,比较两种算法的时间成本来判定哪种算法更好。但实际应用中,T(n)是随着问题的规模n变化的,在事先不知道n的情况下,没法比较两种算法的优劣。由此,引入“Asymptotic behavior”,比较两种算法的T(n)在n比较大时的“增长级数”,例如:对数增长、线性增长、指数级增长。


二、Big Oh notation

In 1892, P. Bachmann  invented a notation for characterizing the asymptotic behavior of functions. His invention has come to be known as big oh notation:

Definition (Big Oh)        Consider a function  f( n) which is non-negative for all integers  tex2html_wrap_inline59063. We say that `` f( n) is big oh  g( n),'' which we write  f( n)= O( g( n)), if there exists an integer 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值