Question

If I want to describe the time complexity of an operation that isn't performed in some program, how could I do this? For example, given the following trivial function:

def trivial():
    return

How could I describe the upper bound on the time consumed by calling Sort? Could I say that the time required by calling Sort is O(0)? This seems to be true given the definition of O-notation.

Was it helpful?

Solution

if some program run for finite no of statements then its complexity is of order 1. complexity is calculated for cases where input size defines the no. of statements executed.

if no of input are n then, complexity is of order n if it runs for n times. if no of input are n then, complexity is of order n^2 if it runs for n*n times, and so on.

if no. of times function executed doesn't depends on input size (or it don't take any input) then its of order 1, no matter how long that function is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top