如何找到以下算法的复杂性?

编程入门 行业动态 更新时间:2024-10-13 04:23:36
本文介绍了如何找到以下算法的复杂性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设模块A需要执行M个单位的时间,其中M是常数。 找到以下algorthim的复数C(n),其中是输入数据的大小 Algorthim: 1-重复I = 1到N 2-重复j = 1到N 3 - 重复k = 1到N 4-模块A [结束步骤3循环] [结束步骤2循环] [结束第1步循环] 5-退出 (观察algorthm使用N代表n)

解决方案

对不起,我们不能为你解决学校问题。通过不自己解决它们,你会松懈。学校和你的作业让你有机会学到一些东西。好好利用这个机会。
-SA

提示:计算第4行是多少次执行。

suppose module A requires M unit of time be executed , where M is constant . find the complexit C(n) of the following algorthim , where is size of the input data The Algorthim : 1- Repeat for I=1 to N 2- Repeat for j=1 to N 3- Repeat for k=1 to N 4- module A [End step 3 loop] [End step 2 loop] [End step 1 loop] 5- exit (observe that algorthm use N for n)

解决方案

Sorry, we don''t solve you school problems for you. By not solving them by yourself, you loose to much. The school and your assignments give you a chance to learn something. Use this chance well.
—SA

Hint: count how many times line 4 is executed.

更多推荐

如何找到以下算法的复杂性?

本文发布于:2023-11-29 22:35:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647825.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复杂性   算法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!