High Level Big-O Notation => Time Complexity

Why is this knowledge important?

Big-O notation can simply be summed up as how “efficient” you’re algorithms run. That’s a very loose summation, but it’s important in the job of software engineering/development and interviews. The latter is what I’ll make a point on. Say you’ve landed a technical assessment interview, solved the algorithm challenge, and passed all the test cases. Now the interviewer may ask you “what’s the time complexity and can you make it better?” Uh oh. Solutions are good but being able to improve efficiency is even better! Take a look at the graph below to get a high level understanding of various time complexities. We’ll get into space complexity a bit later.

source: https://adrianmejia.com/images/time-complexity-examples.png

Example and why this pertains to data structures?

Let’s use a relatively easy data structure that we often use. An array contains a list of “something”, whether that be integers, strings, objects, or even nested arrays/objects. For simplicity sake, we have an arrayOfNum which contains the integers [1, 8, 3, 41, 5]. Now imagine if we have to traverse the array for whatever reason. We will be visiting each integer or index and that is dependent on the size of the array. This would equate to O(N) time complexity because in our example, we will have 5 steps. In a different example with let’s say 1,000 integers, we will have 1,000 steps. To simplify this we say “O of N” to indicate that the steps will be the same as the size or “n” length of the array. I would highly suggest looking up the lookup time of each of the different data structures to be ready in case it’s asked in an interview. The purpose of this blog is for a simple introduction into Big-O notation with time complexity. I’ll be writing about space complexity and in the next blog which involves bits and bytes. Hopefully you’ve found this helpful and stay tuned!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store