in Algorithem analsyis, do we just count when a loop occurs, or does a nested loop get…
- User
in Algorithem analsyis, do we just count when a loop occurs, or does a nested loop get counted only when the body actually does something, like if theres an if condition that doesnt run in the nested loop, does the nesting not count?
- Assistant
Great question! In algorithm analysis, especially when determining time complexity, what matters is the worst-case number of operations executed in relation to the input size ( n ), not necessarily whether a particular statement inside the loop actually runs in some specific execution.