For example, suppose I have an O (n) algorithm and an algorithm that amortizes O (n). Is it fair to say that under strictly significant conditions an unamortized algorithm will always be as fast or fast as a depreciated algorithm? Or are there any reasons to prefer the amortized version (ignoring things like code simplicity or implementation simplicity)?
The main difference between the O (n) algorithm and the amortized O (n) algorithm is that you do not know anything about the worst behavior of the amortized O (n) algorithm. In practice, this does not really matter: if your algorithm is executed many times, then you can rely on the law of averages to balance a few bad cases, and if your algorithm is not executed many times, then you are unlikely to ever encounter the worst case.
, "" , , - . , , , . , , .
, O (n) O (n), , ( ).
-
.
Big O , . .
, O (n ^ 2) n , O (n), .
, , . , - , , .
std::vector, O (1).
:
, big-O , , O (n) , O (n). . , .
, , , . , -, get to add operations. 1000 , , , , . , .
. Big-O , : " , x , ". , , -, . , -, 100 , . , , , , .
Source: https://habr.com/ru/post/1733822/More articles:Why does argv terminate with a null pointer? - cExisting type of routine for messaging routine in Delphi? - delphiTeamCity: launch FxCop after build - teamcityFloating-point exception thrown by rand () In C ++ - c ++Tip: creating a simple database-based CMS in PHP - phpLike gsub slash "/" with backslash and slash "\ /" in ruby - ruby | fooobar.comOpen default browser as standard user (C ++) - c ++Get Windows XP, Windows 7 Current Login Username in VC - apiКак может токенизировать эту строку в java? - javaDebugging Breakpoint - debuggingAll Articles