for(int i = 1;i<=n;i++)
{
for(int j = i;j<=n;j++)
{
//statement -> O(1)
}
}
The time complexity of the first loop (i) is O(n). I mainly have a problem with the second loop.
Thanks!
The overall time (asymptotic analysis) TC would be O(n^2), there will not be exactly n^2 operations!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.