DEV Community

Randi Schreiner
Randi Schreiner

Posted on

When did time get so complex?

So, like all normal people, I hated math in high school. (Just kidding, I know somebody somewhere liked math. I just never knew them.) So when I started learning about Big O and time and space complexity it all seemed WAAAY to complex for me to understand. I vaguely remember words like logrithmic and factorial from years ago but I couldn't have begun to explain what they all meant.

Fortunately, there are lots of people who are way smarter than me who also are really good at teaching! I have now spent hours watching videos and solving problems and I can safely say that I'm starting to understand it! Shout out to smart, patient people!

Really, when it comes down to it, time complexity in most cases (that I've gotten through, I'm sure it gets far more complex) is just a matter of counting. How many things are you asking your function or program or whatnot to do? If it is just making a variable and that's it - woohoo, that's constant! If you are looping through an array, that's going to take as long as the array length, right? So that would be called linear or O(n) if n is the number of items you are looping through.

Now that's really way oversimplifying everything. There are obviously complexities that come with all of that and nothing is ever that simple, but it really does help to think about it in simple terms - break it down first. Sometimes that's the best and only way to solve a problem, make it smaller more manageable problems. Figuring out how to always spot two time complexities makes finding the rest that much easier.

Now I'm on to those more mathy terms like logrithmic ( O(log n) ) and polynomial ( O(n^2) ). But now that I've started learning this stuff, I know I can pick up the rest no problem. Just gotta keep breaking it down until it all makes a little more sense!

R

Top comments (0)