var params = {
TableName : "Users",
FilterExpression : "username IN (:user1, :user2)",
ExpressionAttributeValues : {
":user1" : "john",
":user2" : "mike"
}
};
上述计划的时间复杂度是多少?我认为它应该是O(n ^ 4)。有人可以得到它吗?
答案 0 :(得分:3)
假设输入n
for(i=0;i<n;i++) is O(n)
for(j=0;j<i*i;j++) is O(n^2 /2) since depends on i whose value goes from 1 to n (average of 1..2 is n/2).
for(k=0;k<j;k++) is O((n^2 /2) / 2) since depends j goes from 0 to i*i
然后由于它们是嵌套的,复杂性是循环复杂度O(n *(n ^ 2/2)*((n ^ 2/2)/ 2))= O(n ^ 5/8)的乘积)
其顺序为n ^ 5或O(n ^ 5)
答案 1 :(得分:1)