BigO is tied to some pseudo code

AllDistinct(a1 , . . . , an )
if (n = 1)
return True
for i := n down to 2
   begin
   if (LinearSearch(a1 , . . . , ai−1 ; ai ) != 0)
     return False
   end
return True

Give a big O binding for AllDistinct to run. For a full loan, you must show work or explain your answer.

Thus, the real answer to this in accordance with the solution to this problem is O (n ^ 2). However, since BigO is the worst running time, can I answer O (n ^ 100000) and leave with it? No, they cannot take his points from him, since is the technically correct answer the correct one? Although the more useful O (n ^ 2) is obvious in this algorithm, I ask because we may have a more complex algorithm in the upcoming exam, and if I cannot determine the “hard” attachment, I could make up some extremely large values. and it has to be right, right?

+3
source share
6 answers

Yes, if the function is in O(n^2), it is also in O(n^1000).

If you get a full (or any) loan to answer this question, it depends on the person who is evaluating your exam, of course, so I can’t tell you this (maybe not). But yes, this is technically correct.

If you decide to go this route, you should probably choose something like O(n^n)or O(Ackermann(n)), because, for example, exponential functions are not in O(n^1000).

, , , . , . "n^n , , , , " ". , , O(n^n), , , .

+2

. , , , . , . , . , . ?

( Big Theta , :)

+2

.

HA! ! . ( )

+1

BigO, BigO, , , For full credit, you must show work or briefly explain your answer.

BigO . Upper Bound (BigO);
: , , n ^ 2 (?), - n ^ 2 ( , , , , log (n!)). , n ^ 2 , log (n!). , BigO, , .

, , BigO , ( ), , lowerBound. BigO , .
, , ; BigO , , .. .

+1

, , , , . , , , , - , - , , () , .

0

. , . , , , . " a -O". , , - , .

, - , - . , , , - " , O".

0

Source: https://habr.com/ru/post/1772408/


All Articles