2017-02-15 101 views
-1

我有一个关于渐近时间复杂度的快速问题。下面这个函数的时间复杂度(大O)是什么?根据我的理解,它似乎是无限的递归,因此,这将是什么大O符号?时间复杂度无限递归

def asymptoticTest (int1, int2): 
    if int1 < int2: 
    asymptoticTest(int1 + 1, int2) 
    elif int1 > int2: 
    asymptoticTest(int1 - 1, int2) 
    else: 
    asymptoticTest(int2, int1) 
+0

O(无穷远)?类似于http://stackoverflow.com/questions/5627390/o-notation-o%E2%88%9E-o1 –

+0

在CS Stackexchange上可能有更好的答案,例如http://cs.stackexchange.com/questions/56556/complexity-analysis-of-an-unsolvable-algorithmic-problem – Brandin

回答

1

它需要一个基于输入的恒定时间量(无穷大),所以我称之为O(1)。 O(1)并不意味着“快”,它只是意味着不变。