3 ms·
I do web development, and I think in terms of Big-O notation almost every day. I remember talking with a colleague once who had written some really slow code.
by pjungwir 13y ago
I do web development, and I think in terms of Big-O notation almost every day.
I remember talking with a colleague once who had written some really slow code. He needed to test whether a specific foo was part of a collection of foos, and his collection was an array. Well, that test is O(n), which means it gets slower and slower as your array grows. I said it should be a set or hash, to make the operation O(1), and he had no idea those had different performance behavior. I was shocked. This is about the simplest application of time complexity imaginable, and he had a degree and 5 years of experience.
You should study data structures not so you can implement a linked list (though you ought to do that in your studies), but so you can reason about what your code will do when you have 1000 products/users/whatevers, 100,000, 10,000,000, etc.
As an aside, an interview question I once heard: You have a program that stores the full text of books. Each book is stored in memory as a binary tree of pages. For a book of n pages, what is the time complexity to print all the pages?