Please note that the built-in function took around 308
nanoseconds.
What does this mean?
You can clearly see that Program 2
is twice as fast as Program 1
. This is just a simple example. However if you are building a real-world application, the wrong choice of algorithms can result in sluggish and inefficient user experiences. Thus, it is very important to determine algorithm complexity and optimize for it.