知识卡片
输入规模要按问题对象定义
分析时间复杂度前先声明输入规模:排序通常取元素数,整数乘法需考虑二进制位数,图算法常同时使用顶点数和边数。
同一规模的不同输入仍可能使运行时间不同,因此还要注明分析的是最坏、最好还是平均情况。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第2章 算法入门 · 查看原书依据
Sometimes it is more appropriate to describe the size of the input with more than just one number. For example, if the input to an algorithm is a graph, we usually characterize the input size by both the number of vertices and the number of edges in the graph.
参考来源
- 位置:《算法导论(第4版)》第 2 章 2.2 节“Analysis of insertion sort”(`OEBPS/chapter002.xhtml`)。
- 结论依据:原文逐一比较排序、整数乘法、图的规模度量,并指出相同规模下输入次序会影响插入排序耗时。
- 原始内容:Sometimes it is more appropriate to describe the size of the input with more than just one number. For example, if the input to an algorithm is a graph, we usually characterize the input size by both the number of vertices and the number of edges in the graph.