TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Timecomplexity.ai: GPT-3.5-Turbo Powered Big O Runtime Calculator

1 点作者 bluepanda1234将近 2 年前

1 comment

constantcrying将近 2 年前
Very easily tricked. See e.g. this wrong factorial implementation:<p>int fun(int n){<p>if (n==1 || n==2){<p><pre><code> return 1; </code></pre> }else{<p><pre><code> return fun(1) + fun(n-2); </code></pre> }<p>}<p>&quot;The function recursively calls itself twice, with n-2 and 1 as arguments. This creates a binary tree with a depth of n, and each node has two children. Therefore, the total number of nodes in the tree is 2^n. Since each node represents a function call, the time complexity is O(2^n).&quot;
评论 #36242277 未加载