The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Stephan van Hulst wrote:because the capacity doubles every time. This logarithm cancels out with the linear cost of copying the elements, and so over many calls to ArrayList.add(), the average time becomes O(1).
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Asif Haciyev wrote:but as a entire time complexity we have to take worst case time. Is it true? Did I understand right?
But I didn't get just this sentence. Can you explain please?
Stephan van Hulst wrote:because the capacity doubles every time. This logarithm cancels out with the linear cost of copying the elements, and so over many calls to ArrayList.add(), the average time becomes O(1).
Tim Holloway wrote:What you code isn't always what you get, even at the higher levels. I've already mentioned that we've gone beyond the determinate to the statistical at the machine level.
Most compilers these days have some pretty extensive optimizations. For example, there's loop unrolling:
Campbell Ritchie wrote:And remember that a plain simple if doesn't exist in CS terms; you must always impute an else to it, even if that else is empty.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:all a switch statement is is just a bunch of implied "IF" statements that happen to be predicated on mutually-exclusive conditions.
Liutauras Vilda wrote:
Tim Holloway wrote:all a switch statement is is just a bunch of implied "IF" statements that happen to be predicated on mutually-exclusive conditions.
Not sure I understood you correctly, but that's not true. Perhaps that's true in situations with really few switch cases, but when the number grows switch statements use lookup tables. So it outperforms technically bunch of if-else statements as search of matching condition is O(1) as oppose to bunch of if-then-else goes in a linear fashion.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:the worst-case performance would be O(n+1) where n is the number of cases tested plus optionally a default.
The constant factor is low compared to that for the LinkedList implementation.
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|