Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题反馈:中文pdf版本1.1.0里,rust语言,第37页细胞分裂的递归实现问题 #1577

Closed
hopkings2008 opened this issue Dec 4, 2024 · 1 comment

Comments

@hopkings2008
Copy link
Contributor

rust版本,1.1.0版本里37页复杂度分析里,讲细胞分裂的例子,用递归的实现,rust的代码如下:
第 2 章 复杂度分析 hello‑algo.com 37
fn exp_recur(n: i32) -> i32 {
if n == 1 {
return 1;
}
exp_recur(n - 1) + exp_recur(n - 1) + 1 // 这里不应该有1, 应该把1去掉。 细胞分裂1分为2,2分为4, 4分为。有1的话,就变为1,3, 7 了。
}

hopkings2008 pushed a commit to hopkings2008/hello-algo that referenced this issue Dec 4, 2024
 * correct the implement of exp_recur function and remove +1 operation from the function to simulate the cell division process
krahets added a commit that referenced this issue Dec 4, 2024
* Bug fixes and improvements (#1577)
 * correct the implement of exp_recur function and remove +1 operation from the function to simulate the cell division process

* Update time_complexity.rs

* Update time_complexity.md

---------

Co-authored-by: zouy26 <zouy26@chinaunicom.cn>
Co-authored-by: Yudong Jin <krahets@163.com>
@krahets
Copy link
Owner

krahets commented Dec 4, 2024

这个函数统计的是“分裂总次数”而非“细胞数量”。例如,n = 2 代表进行了两轮分裂,包括:一分为二(1 次)、二分为四(2 次),此时分裂总次数为 1 + 2 = 3 。

@krahets krahets closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants