+ 6
Big "O" notation...
How often do you consider Big O when writing your programs? Does it even matter as long as the solution works?
6 ответов
+ 11
It matters if you care about performance.
If I have an idea of how to write a program what I focus on is: what's the most optimital solution¿
That includes making something work.
Algorithms that are O(n^4) or even O(n^3) are usually impractical.
+ 6
I will do a quick Big O calculation after every loop I write, it's just so useful. If you can get that O(n²) down to a O(n log n) that makes a huge difference if you're processing as little as 1000 things.
+ 4
Usually big o is taken in consideration when u r a hardcore devloped and developing a huge code or application but we should practice big o to the best case so we get habituated to it but never did this😂😂
+ 2
Thank you for the answers... the reason I actually asked was I noticed sololearn playgrounds put time limits on some loops I wrote... like in "super perfect number challenge", some people's code could do calculations for a bigger range of numbers and mine a smaller one...
+ 2
I don't actually sit down and calculate it but I usually think about the effects of loops within loops and being in efficient when writing real world code. Like, "how bug can this input size get" or "what would be the effect of a really large input to this" and "is there a more efficient way"
0
Big O notation is very useful when you choose a collection. For example search perfomance for an element is linear for array/list but a constant for dictionary/hashset