小白,求大神指教时间复杂度
inti,j
for(i=0;i<n;i++){
for(j=i;j<n;j++){
/*时间复杂度为O(1)的程序步骤序列*/
}
这个循环时间复杂度为O(n²)为什么不算外循环n次
不应该是(n²/2+n/2)*n
kathria
浏览 1345回答 2
2回答
-
慕瓜9220888
HDYKZVFVHPGYGFIBERRJUPBBZWMJKFKDWWICYTBQOBOLEWEWEGQPSPXBGLQXFOYNEWVQQNMGOLDYQGTTZNMLDCDQARRZAHDZWPYDEWYNQGJHIJOWSBBEOHEQFHKTTZXYKCEUQADICEZVOVIADKSURUHXRLMKWVOBUMTRJBQCWPXFXWPOPMCTZTEQXUGGQEJHTOBEUALCHNFOIHEOCLQVGZCWMQVNPPZLWWXPEGZZFFEJUVQQTMZZTITPSLEZSNVHGZMLINEFEBNQJZAECLTGGEASQPHFZLVBLGPAVPBBRWXFRTOXHDYCRDLLGTSAHPUGGFSWPMRNHADWJKLXMXFPBLTEPBQTPMMHOQOQTMJPRSUJDPFCMTUWIAJTSVSDMHCMPIIBYTBQAJPPFKYAWPGVRDUSKJWMPSFWMODQGMSSZLACFBHXEMXMYYREQOZRGLKDGZBWRJVBOKUPHSHGCFLSCTSUHUTWWXIDFYFVCMPSHSREHNJDYAYOUXJDUZXZUNEDNCTBAUXDGMFGITFSIEYBSDVRANWZLCHTBQWSSUFEJEUKDAYDVWFVUBUSXVXSIKHGZKHPERBNPXYDGZIFVHGWOGIOXUKDECKZYOKNRYAFBUXKUUFXZOHQAGDGAJJWURIPHNBUXNNVHJGFLTGUEOSAJBZIVAPDBKCSOIRLTCHTZIFPVWEAJPYLVQVEYYYKUDEYUFHWZSOOZAGVSLILWXFXZPLBIZDMKGZCAGYTIKJFVOVEPBQLVWMJBVMRZWPCVMQPEFIIFOQVKFUQAQTWAZYDMWJSUJRTYRUXXSDCLMFYFISDYQCLLOOEPKCKXHTDIQIAQTZGGNYQYAADSBGLDVQNDGCFJYQIYHENJHZLQTZSCHWWYHATGZXHGIDGJMGQXZOTJJWPKVD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