Yes performance is a feature but realistically you can get away with some fairly awfully performing code for a long time in most situations.
I remember a conversation a while ago where people we asking if you could have a language that offered X increase in performance over C for X increase in processing time what value of X would you pick? In most cases people are willing to trade a lot of performance for a lot of productivity.
If they can tell you in Big O notation why its bad for large inputs then great, but so long as they can tell you why that's what really matters.
That is -- anytime you write a loop, you'd better think about what's inside it (and how long those things will take), and -- given the amount of data you might be sending through that loop -- if that's a problem or not.
I want someone to notice that they're making a remote call in a loop when it could be batched, cached, etc.. I don't want them to spend 2 days optimizing an algorithm tinkering with a bit of text that yes, is inefficient, but in practice is only going to take a few milliseconds anyway and isn't a hotspot.
interviewer : "what's the time complexity of blah"
me : "hmm... O(1)"
interviewer : "what's the space complexity?"
me : "fuck, oh, I don't know"
interviewer : "well, think about it. no stress"
me (2 seconds later) : "oh, right, yeah, O(n)... of course"
Not saying I'm proud of not taking the time to think a problem through, but sometimes people act really weird when under the gun.
Trite though it is, admitting that you don't know truly is on the path to wisdom.
Not taking time to think things through is endemic in the workplace, not just an interview quirk.
in the real world, many O(N) algorithms are in fact O(I don't know) because of unexpected or unpredicted behavior from language, compiler, interpreter, runtime, os, etc.
O(N^2) means that your operation gets n times slower each time n increases.
2000^2 is 4 million. (n log n = 6600)
200,000^2 is 40 billion. (n log n = 1 million)
My point is for a lot of cases it doesn't matter, and just because someone can't throw off the top of their head the O complexity of some algorithm they just wrote in a stressful interview does not mean they don't understand the concepts.
Besides a O(N log N) algorithm over 10 or 100 items is not going to cause any issues. In the case of your standard CRUD application that's what you are going to be dealing with.
> Besides a O(N log N) algorithm over 10 or 100 items is not going to cause any issues. In the case of your standard CRUD application that's what you are going to be dealing with.
I think you mean n^2. n log n is generally considered pretty decent.
But you're wrong, I know from experience that simple CRUD apps can suffer from grindingly poor performance, caused by, let's say, optimistic assertions of data volumes.
I am yet to have seen a basic CRUD app that had performance issues due to a bad coding algorithm. Certainly from poor queries but never from an bad algorithm.
Keep in mind I would say that a simple CRUD app with millions of entries is no longer a simple CRUD app.
select * from table;
But yeah, case in point: I ran a small BB-style web forum a number of years ago. As it grew larger (on the order of 10k posts - hardly earth shattering for a web forum), the load on the server got unsustainable, and the page loads were really slow. It turned out that the algorithm to decide if a user had seen a post was to maintain a list of seen post IDs for each user, and compare them at each page view. For active users, the number of seen posts obviously approaches the number of posts: n^2.
I didn't mention not being able to reason out the complexity, only saying its O(N^2) off the top of your head when presented with some method.
To be sure, not being able to reason outside of the canon is a long-standing occupational hazard and trait of the humanities, so there could be something a little more pathological in perpetuating these interviewing techniques.
Not nearly as relevant for someone using scripting languages and building UIs.
I've used slow web pages that show a lot of items or data. One way to make them slow is O(n^2) DOM manipulation (e.g., inside a loop over items in a page, O(n)-searching the page for something).
Knowing complexity theory isn't the only way to find performance problems, and sometimes isn't even relevant, but it sure is helpful.
Sometimes you have to make a decision to just go with the inefficient solution, but I'd like it to be an informed decision if the codebase is one I have to work with and maintain in production.
The employee had to explain that they couldn't deploy this algorithm because it was O(N^3) whereas the (already deployed) one that was doing worse on the test-data was O(N log N). The test-data was two orders of magnitude smaller than what could reasonably be expected while deployed.