Skip to Content
复杂性思考:复杂性科学和计算模型(原书第2 版)
book

复杂性思考:复杂性科学和计算模型(原书第2 版)

by Allen B. Downey
March 2020
Intermediate to advanced
200 pages
3h 12m
Chinese
China Machine Press
Content preview from 复杂性思考:复杂性科学和计算模型(原书第2 版)
29
因此,这个函数的增长级数是 O(
n
+
m
),我们可以说,无论
n
m
哪个更大,
运行时间与
n
m
成正比。
如果知道
n
m
之间的关系,我们可以简化这个表达式。例如,在一个完全
图中,边的数目是
n
(
n
–1)/2,在
O
(
n
2
) 中。对于一个完全图,reachable_
nodes
n
的二次函数。
2.9 练习
本章的代码在 chap02.ipynb 中,它是本书代码库中的 Jupyter 笔记。有关
使用此代码的更多信息,请参阅前言中的“使用代码”。
练习 2-1
启动 chap02.ipynb 并运行代码。你可能想在笔记本上做一些简单的
练习。
练习 2-2
2.8 节中,我们分析了 reachable_nodes 的性能,并将其归类为
O(
n
+
m
),其中
n
为节点数,
m
为边数。请继续分析,is_conected
增长级数是什么?
def is_connected(G):
start = list(G)[0]
reachable = reachable_nodes(G, start)
return len(reachable) == len(G)
练习 2-3
在我的 reachable_nodes 实现中,你可能会为将所有相邻节点添加到
栈而没有检查它们是否已经在集合 seen 中而感到困扰。重新编写一个函
数,在将相邻节点添加到栈之前检查它们是否已经存在于栈中。这种优
化会改变增长级数吗?这会使函数运行得更快吗?
练习 2-4
实际上有两种 ER 图。本章生成了其中一种,G(
n
,
p
) 由两个参数表示,节 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

数据驱动力:企业数据分析实战

数据驱动力:企业数据分析实战

Carl Anderson
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua
流畅的Python

流畅的Python

Luciano Ramalho

Publisher Resources

ISBN: 9787111647348