In this blog post, I’m going to summarize what I learned so far in Colt Steele’s Data Structures and Algorithms course from Udemy. So far I have learned about Big O Notation.
Big O notation is useful when there are more than one implementation of the same function. There needs to be a numeric representation of how the code performs, be it good or poorly.
This type of notation gives engineers precise vocabulary to discuss how the code performs. It’s also useful for discussing trade-offs between different approaches to problem solving. Engineers need to be able to identify problems and inefficiencies in the code.
When engineers discuss what make code better than other code, there are several factors that come into play. Is the code faster than other solutions? Does it take up less memory? Is it more readable for other engineers?
In regards to the speed of the code, it pertains to how long the code takes to execute. But there are problems with measuring code speed this way. Different machines will record different times and even the same machine will record slightly different times from each run. And also, for very fast algorithms, trying to measure speed may not be feasible as the run times would be extremely short.
So engineers don’t use time but rather how many simple operations the computer has to perform in order the run the code. This is called time complexity.