算法导论第三版 第3章习题答案

article/2025/10/19 21:08:36

2020/10/28:初稿,参考https://ita.skanev.com/,修订参考文献的部分错误

2020/10/30:修订第二节第4题的证明错误(参考https://blog.csdn.net/qq_36414798/article/details/81028403)

3 Growth of Functions

3.1 Asymptotic notation

1.Let f(n) + g(n) be asymptotically nonnegative functions. Using the basic definition of Θ-notation, prove that max(f(n),g(n))=Θ(f(n)+g(n)).

From asymptotically nonnegative, we can assume that:

\begin{align*} \exists n_1, n_2: & f(n) \geq 0 & \text{for } n > n_1 \\ & g(n) \geq 0 & \text{for } n > n_2 \end{align*}

Let n_0 = max(n_1, n_2) , some obvious things for n > n_0:

f(n) \leq \max(f(n), g(n)) \\ g(n) \leq \max(f(n), g(n)) \\ \big(f(n) + g(n)\big)/2 \leq \max(f(n), g(n)) \\ \max(f(n), g(n)) \leq f(n) + g(n)

From the last two inequalities, we get:

0 \leq \frac{1}{2}\big(f(n) + g(n)\big) \leq \max\big(f(n), g(n)\big) \leq f(n) + g(n) \quad \text{for } n > n_0

Which is the definition of\Theta(f(n) + g(n)) with c_1 = 1/2, c_2 = 1

2.Show that for any real constants a and b, where b>0,(n + a)^b = \Theta(n^b)

(n + a)^b = \binom{n}0n^b + \binom{n}1n^{b-1}b + \cdots + \binom{n}0a^b

The most significant term is n^b and this is obviously polynomially tightly bound.

3.Explain why the statement, "The running time of algorithm A is at least O(n^2) is meaningless.

The O-notation provides an upper bound. "At least" implies a lower bound.

4.Is 2^{n+1} = O(2^n) ? Is 2^{2n} = O(2^n) ?

Yes, because if we choose 2 for both constants in the O-notation definition, we get an equality.

No, because \nexists c: 2^n \cdot 2^n \leq c 2^n

5.Prove Theorem 3.1

The theorem states:

For any two functions f(n) and g(n), we have f(n)=Θ(g(n)) if and only if f(n)=O(g(n)) and f(n)=Ω(g(n))

6.Prove that the running time of an algorithm is Θ(g(n)) if and only if its worst-case running time is O(g(n)) and its best-case running time is Ω(g(n)).

7.Prove o(g(n))∩ω(g(n)) is the empty set.

8.We can extend our notation to the case of two parameters n and m that can go to infinity independently at different rates. For a given function g(n,m) we denote O(g(n,m)) the set of functions:

\begin{align*} O(g(n, m) = \lbrace f(n, m): &\text{there exist positive constants } c, n_0, \text{ and } m_0 \\ &\text{such that } 0 \leq f(n, m) \leq cg(n, m) \\ &\text{for all } n \geq n_0 \text{ or } m \geq m_0. \end{align*}

Give corresponding definitions for Ω(g(n,m)) and Θ(g(n,m)).

3.2 Standard notations and common functions

1.Show that if f(n) and g(n) are monotonically increasing functions, then so are the functions f(n)+g(n) and f(g(n)), and if f(n) and g(n) are in addition nonnegative, then f(n)⋅g(n) is monotonically increasing.

2.Prove equation (3.16)

\begin{align*} a^{\log_bc} = a^{\frac{\log_ac}{\log_ab}} = \big(a^{\log_ac})^\frac{1}{\log_ab} = c^{\log_ba} \end{align*}

3.Prove equation (3.19). Also prove that n!=ω(2^n) and n!=o(n^n).

 4.Is the function ⌈lgn⌉! polynomially bounded? Is the function ⌈lglgn⌉! polynomially bounded?

⌈lgn⌉! is not polynomially bounded, but ⌈lglgn!⌉ is.

If we take the definition of polynomially bound:
f(n) \leq cn^k

and take the logarithm of each side, we get:

\lg{f(n)} \leq \lg{c} + k\lg{n}

Thus, a function is polynomially bound if \lg{f(n)} = \O(\lg{n})

In the following proofs, we will make use of the following two facts:

lg(n!) = Θ(nlgn) (by equation (3.19))

⌈lgn⌉ = Θ(lgn), because

· ⌈lgn⌉  ≥ lgn

· ⌈lgn⌉  ≤ lgn + 1 ≤ 2lgn, for all n ≥ 2

lg(⌈lgn⌉!) = Θ(⌈lgn⌉lg⌈lgn⌉) = Θ(lgn lg lgn) = ω(lgn).Therefore, lg(⌈lgn⌉!) ≠ Ο(lgn), and so ⌈lgn⌉! is not polynomially bounded.

lg(⌈lglgn⌉!) = Θ(⌈lglgn⌉lg⌈lglgn⌉) = Θ(lglgn lg lglgn) = o((\lg{\lg{n}})^2)o(\lg^2\lg(n))   = ο(lgn) .

The last step above follows from the property that any polylogarithmic function grows more slowly than any positive polynomial function, i.e., that for constants a, b > 0, we have \lg^b{n}o(n^a). Substitute lgn for n, 2 for b, and 1 for a, giving\lg^2{(\lg{n})}=o(lgn).

Therefore, lg(⌈lglgn⌉!) = Ο(lgn), and so ⌈lglgn⌉! is polynomially bounded.

5. Which is asymptotically larger:\lg(\lg\textup{*}{n})or\lg\textup{*}(\lg{n})

The second, because:

\lg\textup{*}(\lg{n}) = \lg^*n - 1 > \lg(\lg\textup{*}(n))

6.Show that the golden ratio ϕ and its conjugate \hat \phi both satisfy the equation x^2 = x + 1.

7.Proove by induction that the ith Fibonacci number satisfies the equality

F_i = \frac{\phi^i - \hat{\phi^i}}{\sqrt5}

Base:

\frac{\phi^0 - \hat{\phi^0}}{\sqrt{5}} = \frac{1 - 1}{\sqrt{5}} = 0 = F_0

\frac{\phi - \hat{\phi}}{\sqrt{5}} = \frac{1 + \sqrt{5} - 1 + \sqrt{5}}{2\sqrt{5}} = 1 = F_1

Step:

F_{n + 2} = F_{n + 1} + F_n = \frac{\phi^{n+1} - \hat\phi^{n+1}}{\sqrt{5}} + \frac{\phi^n - \hat{\phi^n}}{\sqrt{5}} = \frac{\phi^n(\phi + 1) - \hat{\phi^n}(\hat\phi + 1)}{\sqrt{5}} = \frac{\phi^n\phi^2 - \hat{\phi^n}\hat{\phi^2}}{\sqrt{5}} = \frac{\phi^{n+2} + \hat\phi^{n+2}}{\sqrt{5}}

8.Show that k\ln{k} = \Theta(n) implies k = \Theta(n/\ln{n}).

Problem

3.1 Asymptotic behavior of polynomials

3.2 Asymptotic behavior of polynomials

Indicate for each pair of expressions (A,B) in the table below, whether A is O, o, Ω, ω, or Θ of B. Assume that k≥1, ϵ>0, and c>1 are constants. Your answer should be in the form of the table with "yes" or "no" written in each box.

Note:lg(n!)=\Theta(nlgn)

3.3 Ordering by asymptotic growth rates. 

a.Rank the following functions by order of growth;that is, find an arrangement g_1, g_2, \ldots , g_{30} of the functions g_1 = \Omega(g_2), g_2 = \Omega(g_3), \ldots, g_{29} = \Omega(g_{30}). Partition your list into equivalence classes such that functions f(n) and g(n) are in the same class if and only if f(n) = \Theta(g(n)).

b.Give an example of a single nonnegative function f(n) such that for all functions gi(n) in part (1), f(n) is neither O(g_i(n)) nor \Omega(g_i(n)).

The order is thus:

  1. 1 = n^{1/\lg{n}}
  2. \lg(\lg^*n)
  3. \lg\textup{*}n \simeq \lg\textup{*}(\lg{n})

The asked function can be:2^{2^{(n + 1)\sin{x}}}

3.4 Asymptotic notation properties

3.5 Variations on O and Ω

3.6 Iterated functions


http://chatgpt.dhexx.cn/article/MO5M7GIG.shtml

相关文章

算法导论第四版

摘要: 算法导论第四版介绍 【对算法,数学,计算机感兴趣的同学,欢迎关注我哈,阅读更多原创文章】 我的网站:潮汐朝夕的生活实验室 我的公众号:算法题刷刷 我的知乎:潮汐朝夕 我的github&#xff…

山东大学软件学院2021算法导论期末试题

山大软院算法期末题回忆版 可能乱序and有差错,仅供参考 老师会捞的 题目都很简单 不需要太复习 1.三种时间复杂度比较异同 2.T(n)T(n*3/4)nlogn 求T(n)的最大上界 3.npc问题证明 4.强连通分量 算法思想和证明 5.图三个证明 (1)证明最短路的…

算法导论第三版 第29章习题答案

参考文献: https://walkccc.me/CLRS/Chap29/29.1/https://sites.math.rutgers.edu/~ajl213/CLRS/ 29.Linear Programming 29.1 Standard and slack forms 1.If we express the linear program in (29.24)–(29.28) in the compact notation of (29.19)–(29.21)…

算法导论 观后感一

此文章只作为自己看算法导论的一些理解和想法,希望自己能坚持下去。 算法的在计算中的应用 什么是算法?算法的作用?为什么要研究算法?对于算法我常有的想法是必然和数学相关,而且必定是高等数学之上的。甚至很多目前…

《算法导论》常见算法总结

前言:本篇文章总结中用到很多其他博客内容,本来想附上原作链接,但很久了未找到,这里关于原创性均来源于原作者。 分治法 分治策略的思想: 顾名思义,分治是将一个原始问题分解成多个子问题,而…

算法导论复习题

文章目录 第一章 复杂度第二章 递归与分治2.1 排列问题2.2 整数划分问题2.3 分治时间复杂度2.5 汉诺塔时间复杂度2.6二分搜索时间复杂度2.7 金块问题2.9 棋盘覆盖复杂度2.10 合并排序时间复杂度2.11 快速排序2.11 线性时间选择 第三章 动态规划3.1 矩阵连乘问题3.2 最长公共子序…

算法导论 pdf_下载算法导论_高清_pdf

关注我,持续更新好资料 点击下方链接,获得资料 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 这个公众号全是好资料,干货满满 算法导论pdf下载_书籍大小55M 此内容,仅限个人阅读,不得翻印,不得上传网络,不得用于谋利。 若因传播引起任何纠纷,由下载者自行负责。…

算法导论

1.算法在计算中的作用 1.1算法 算法解决哪些问题 数据结构 技术,算法设计分析技术 难题,PE完全问题 并行性 1.2作为一种技术的算法 效率 算法与其他技术 2.算法基础 2.1插入排序 代码 public static void main(String[] args) {int[] array {5, 2, 4, 6…

书评《算法导论》

最近空闲时间在看《算法导论》。由于之前有数据结构与算法的基础,并且也写过几百道代码题。所以现在看这本书反而有了一些更深的感悟。 《算法导论》确实不适合初学者,尤其是不适合实践派。对于实践派,《数据结构与算法分析——C语言描述》、…

蓝牙sbc怎么解决_【科普】蓝牙音频常用的编解码格式

蓝牙耳机的参数你是否都了解,那些看起来貌似高大上的技术是如何改变蓝牙音质和传输稳定性的,下面dy君就带你了解主流的几种蓝牙音频编码格式: SBC (Sub-band coding,子带编码) 最早的格式应该是SBC,SBC是A2DP(Advanced Audio DistribuTIon Profile,蓝牙音频传输协议)…

蓝牙音频双剑客(二)--高质量音频分布协议(A2DP) 连接播放音乐断开流程(被连接)介绍

零. 概述 主要介绍下蓝牙协议栈(bluetooth stack)传统蓝牙音频协议之高质量音频分布协议(A2DP) 连接播放音乐断开流程(被连接)介绍 一. 声明 本专栏文章我们会以连载的方式持续更新,本专栏计划更新内容如下: 第一篇:蓝牙综合介绍…

基于AVDTP信令分析蓝牙音频启动流程

前言 公司项目edifier那边需要在原来音频SBC,AAC基础上增加LHDC5.0编码,在打通lhdc协议栈之前,学习记录一番AVDTP音频服务流程。 一、AVDTP音频流基础知识 分析音频流程首先应具备的最简单基础概念知识:AVDTP信令signal,流端点se…

蓝牙音频广播多连接模块技术方案

蓝牙我们应该都很熟悉,现在的蓝牙应用在生活中随时随地都可以见得到,尤其是蓝牙音频;常见的蓝牙一般都是点对点的,或者就是TWS,一拖二功能,但是有一些使用场景,是需要一拖多的,需要多个音响同步…

当前市场主流蓝牙音频SOC

2020年5月9日更: 目前安卓已经全面支持LDAC了,讨论其他格式的蓝牙音频方案已经没多大意义了。 对于真无线耳机方案来说,也就剩高通和苹果了,开发者可选也就高通了。 这个市场已经归一统了~~~~~~不要看下面的内容浪费时间了。 -…

海贝思蓝牙接收器Linux,Hagibis海备思 蓝牙音频接收 耳机怎么样,评测

Hagibis海备思 蓝牙音频接收 耳机怎么样,评测: 1、很不错,与车子AUX连接电话声音很青楚,物有值 2、还行,免提打电话效果还可以,就是充电线和音频线一起走的那么细一根线,我也是醉了。声音效果一般&#xff…

蓝牙音频编码简介 - SBC、AAC、AptX、LDAC、LHDC

https://zhuanlan.zhihu.com/p/265597723 早在2000年,蓝牙耳机就已经出现,但由于技术限制,只能用于通话。2008年,随着蓝牙A2DP(Advanced Audio Distribution Profile)开始普及,立体声蓝牙耳机日渐流行。发展到现在&am…

蓝牙技术|伦茨科技带你了解蓝牙音频

蓝牙设备在日常生活中随处可见,用蓝牙耳机或音箱听音乐已经成为蓝牙最主流的应用之一。这些都用到我们的蓝牙音频技术。 蓝牙音频协议HFP,HSP,A2DP,AVRCP,OPP,PBAP HFP HFP(Hands-free Profile)&#xf…

蓝牙基础:蓝牙音频

前言 蓝牙耳机中存在两种 通话音频 和 音乐音频两种音频。 1 通话音频 1.1 音频链路 通话中的音频数据(Audio)直接通过基带上的SCO链路进行传输 音频通路(1) Audio-》Voice-》SCO/eSCO-》HCI-》Baseband(2) Audio-》Voice-》PCM-》Baseband这两种方…

ZYNQ平台Linux4.6内核蓝牙音频

第1章 RTL8723BU蓝牙模块驱动移植 1.1. 硬件方案 1.2. 蓝牙驱动移植 1.3. 蓝牙耳机规格要求 第2章 Linux音频框架 2.1. ALSA 2.2. Pulseaudio 2.3. GStreamer 2.4. Jack 2.5. FFADO 2.6. Xine 2.7. Phonon 2.8. 其他分支 第3章 蓝牙协议栈Bluez 3.1…

蓝牙的音频通路

如上图: 音频通路1:Audio->L2CAP->ACL->HCI->Baseband,a2dp音频走这种方式; 音频通路2:Audio->Voice->SCO/eSCO->HCI->Baseband,hfp、hsp蓝牙通话走这种方式; 音频通路…