如何找到以下算法的复杂性? [英] how to find complexit of the following algorithm ?

查看:60
本文介绍了如何找到以下算法的复杂性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设模块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.


这篇关于如何找到以下算法的复杂性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆