算法导论 Exercises 22.5

本文详细探讨了《算法导论》英文第三版中的第22.5节练习题,深入解析关键概念和解题思路。
摘要由CSDN通过智能技术生成

Exercises 22.5 - 算法导论.英文第3版 

最近看书的同时, 感觉一些练习缺少参考, 所以按部分总结了自己的解答, 也能够强化学习过程. 
如有不足或疑问, 欢迎指正. 


Exercises 22.5-1
How can the number of strongly connected components of a graph change if a new
edge is added?
可以将每个强连通组件当作一个顶点, 组成强连通图, 图内顶点数量即强连通组件数量.
如果新增加的边在顶点内部(即指向自己), 或者重复已有顶点间的边, 则数量没变化. 
如果新增加的边使图形成环,  这样环内顶点组成一个新的强连通组件, 所以数量减少N, N = (环内顶点数量 - 1).


Exercises 22.5-2
Show how the procedure STRONGLY-CONNECTED-COMPONENTS works on the
graph of Figure 22.6. Specifically, show the finishing times computed in line 1 and
the forest produced in line 3. Assume that the loop of lines 5–7 of DFS considers
vertices in alphabetical order and that the adjacency lists are in alphabetical order.



按照字母排序的循环和邻接表, 可得出第一次DFS访问顶点顺序, 如下
(q   (s (v (w, w) v) s)   (t (x (z, z) x)  (y, y) t)   q)   (r (u, u) r)   

finishing time: f(r) 20, f(u) 19, r(q) 16, f(t) 15, f(y) 14,
                     f(x) 12, f(z) 11, f(s) 7, f(v) 6, f(w) 5.

根据 finishing time 降序排列, 并倒转上图中的边, 第二次DFS访问顶点顺序, 如下
(r, r) *  (u, u) *  (q (y (t, t) y) q) *  (x (z, z) x) *  (s (w (v, v) w) s)
每个不相关括号(用*间隔)内的顶点, 代表 line 3 生成的树(即强连通组件)


Exercises 22.5-3
Professor Bacon claims that the algorithm for strongly connected components
would be simpler if it used the original (instead of the transpose) graph in the
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值