算法的时间兼容性 [英] Time-compexity of algorithms

查看:105
本文介绍了算法的时间兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我遇到一个问题,我对它的答案感到困惑.我必须找到算法的时间复杂度.该算法说我有一个大小为n的数组,并且要在数组的每个元素上执行5个操作.所以我想出了以下答案,我必须总共执行5 * n次运算,对吗?所以它的时间复杂度大约为n?

Ok so I came across a question and I am confused about its answer. I have to find the time complexity of the algorithm. The algorithm says that I have an array of size n and on each element of the array 5 operations are to be performed. So I came up with the following answer that I have to perform 5*n operations in total on it right? so it's time complexity would be of the order n?

推荐答案

是.

如果每次操作所需的时间都是恒定的.

If the time required for each operation is constant.

但这还取决于操作是什么.

But also depends on what the operations are.

这篇关于算法的时间兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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