How would Big-O notation help in my day-to-day C# programming? Is it just an academic exercise?
Naw, I was wondering that too, but now I find myself thinking about big-O just about every time I use a library.
Big-O lets you know the asymptotic running time of any function, that way you can decide whether data structure A is faster than data structure B for your purposes.
For example, you might be tempted to use something like an ArrayList
when what you really need is a Queue
. When you try to add an element to an ArrayList
, if you can see that the running time is O(n)
(because it needs to create a new array and copy all the elements over... sometimes) but in a Queue
it's O(1)
then you can easily see that the queue would be faster. This is actually kind of a poor example as there are many other differences between these two structures, but you get the idea ;)