문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top