Live data from Hacker News

I had to give a wrong answer to get the job (2017)

dewitters.com

401–409 of 409 posts

Re: I had to give a wrong answer to get the job (2017)

#401

Earlier quoted context omitted.

> It's not great to have to double your memory usage while you reallocate your array. You don't have to use a growth factor of 2. Any constant multiple of the current size will give you amortized constant complexity. > On more limited devices (see games consoles or mobile devices) you'll end up fragmenting your memory pretty quickly if you do that too often and the next time you try to increase your array you may not…

When you reallocate your array you will in memory have your old array and your new larger array while you move your data over. At the very least you're using 2x and the extra memory for your expansion. For your other points if you'd mentioned them in the interview you'd probably have been better received. Copying is really only that fast for POD objects (your objects copy constructors may need to do reallocation them…

A typical C implementation would be using realloc():

The realloc() function tries to change the size of the allocation pointed to by ptr to size, and returns ptr. If there is not enough room to enlarge the memory allocation pointed to by ptr, realloc() creates a new allocation, copies as much of the old data pointed to by ptr as will fit to the new allocation, frees the old allocation, and returns a pointer to the allocated memory.

Worst case definitely 2x memory. But not necessarily always.

Re: I had to give a wrong answer to get the job (2017)

#402
post #216

Earlier quoted context omitted.

This is dangerous, but if well documented and understood it might be okay. Some data might contain unique things (for argument's sake, say a std::unique_ptr). It can get tricky since you need to know the implementation details of everything that gets inserted and it's ownership behavior, since elements can be kept at two places. (A copy in array n and one in 2n.) Then there is the fact that you basically make every i…

> Then there is the fact that you basically make every insertion 3x as costly. You better have a good reason to need this given the additional complexity and caveats. > As for the original interview question, there are systems where an occasional longer pause is not OK. As you say, it's a tradeoff between worst-case operation cost and average operation cost: If you allow any worst-case operation cost, you can get rea…

To be clear, there is no tradeoff in the number of operations. You are doing the exact same number on average (or total or amortized), while improving the worst-case.

You do lose the ability to do a no-copy realloc() though, and increase the average memory use (not peak).

Re: I had to give a wrong answer to get the job (2017)

#403

Earlier quoted context omitted.

Years ago the did an experiment in Germany (I know, a one time test with 2 cars/drivers is more or less anecdata). The task was to drive from Duesseldorf to Munich. Two identical cars, two very experienced drivers. one was told to go as fast as possible without breaking speed limits on the way (we don't have a general speed limit on the German Autobahn (highway)) tthe oother ro drive at a relaxed 120 km/h were possib…

Counter anecdata. I monitor my heartrate (along with other relevant statistics like speed, distance, elevation, and barometric pressure) while engaged in activities like mountaineering. Even when I'm not physically straining myself but just carefully traversing an exposed face, I don't consider a raised heartrate there 'less healthy' in and of itself because it's a side-effect of the excitement I'm feeling, and that…

To clarify:

The spikes and reactions were stress reactions measured by medical doctors from the monitoring of multiple signals (heart rate being one).

So they came to the experimental conclusion that (at least in this experiment) driving at the limit of what was possible in terms of speed the car could go and speed traffic would somehow allow was a factor of stress for the driver.

They also qualified the added amount of fuel necessary to drive the distance.

But they did not say one was better, one was worse. They just let the viewer decide on which variant they preferred.

And as I said: If the externalities were priced into taxes and cost of fuel - why not let people and the market decide if it was worth to them to arrive 20 minutes quicker on this distance.

Re: I had to give a wrong answer to get the job (2017)

#404

Earlier quoted context omitted.

Counter anecdata. I monitor my heartrate (along with other relevant statistics like speed, distance, elevation, and barometric pressure) while engaged in activities like mountaineering. Even when I'm not physically straining myself but just carefully traversing an exposed face, I don't consider a raised heartrate there 'less healthy' in and of itself because it's a side-effect of the excitement I'm feeling, and that…

Along those lines there's a notable pop-sci book by Robert Sapolsky, "Why Zebra's don't get ulcers" ( https://www.amazon.com/Why-Zebras-Dont-Ulcers-Third/dp/08050... ). Basically this guy made his scientific career by doing epic experiments where he observed communities of baboons during various social interactions, blow-gunned individual baboons with tranquilizers, then very quickly, took samples of their blood to a…

> but I do care about their propensity to cause accidents and hurt innocent people

Absolutely agree. I live in a 30km/h zone (regular speed in a city is 50km/h in Germany). And we have speeders every day. While kids are playing and elderly people trying to cross the streets.

What I wanted to say:

I care - and we petitioned the city to at least have marked parking spaces implemented with big flower pots on every side to at least reduce the speed people can go here.

Re: I had to give a wrong answer to get the job (2017)

#405

Earlier quoted context omitted.

> None of the comments above yours in the thread mention any form of the word "fast" or "speed". They mention "performance" in reference to big-O complexity. Big-O is not always about speed. I am sorry, do you want to say "performance" and "big-O" have nothing to with trying to make the program go faster? I think you have lost your way and need to backtrack a little bit. The whole point of big-O analysis is to be abl…

If I ask for something to be done in O(1) I'm not asking for it to be fast, I'm asking for it to take the exact same amount of time every time no matter what. That might end up being slower, but so what, maybe that's what I need. If I ask for an O(1) algorithm and you build something that is as fast as possible, faster in every case, but sometimes it's really fast and sometimes it's a little less fast but still fast…

> Thus, I do not consider big-O to be synonymous with speed. They are different, because the best possible big-O, O(1), does not necessarily mean the fastest.

Maybe not synonymous in the sense of technically exactly equal, but certainly a pretty good approximation -- and absolutely synonymous in the sense that the whole purpose of big-O notation is to be able to reason about speed in more general terms, comparing algorithms in pseudo code in stead of having to actually write the program so you can run it through a benchmark.

So, no: If "the best possible big-O, O(1), does not necessarily mean the fastest," then it isn't actually the best.

Re: I had to give a wrong answer to get the job (2017)

#406
post #23

Earlier quoted context omitted.

I used to do a very stupid magic trick where I would have someone pick a card and then shuffle it back into the deck. I would shuffle a few more times while asking them to focus on their card. Then I would ask them to name their card. They did. I would put down the deck and say "not only have I found your Ten of Clubs..." and then I would look at the top card and finish with "...but I have changed it into the Ace of…

Dai Vernon had something akin to that. I -assume- it was the serendipitous case you mention, but it is, after all, anecdote, so it might have been something more. But, pulling from Wikipedia - 'He also had an encounter with another up-and-coming young magician from his town, Cliff Green, who asked Vernon, "What kind of magic do you do?" Vernon responded by asking the boy to name a card. Upon pulling a pack of cards f…

Bah, that's an easy one: To begin with, make sure what you're wearing has a total of at least fifty-two pockets...

Re: I had to give a wrong answer to get the job (2017)

#407

I was once asked to write a function that, given the time, draw an analog clock. Given the nature of the position I was applying for, this wasn't an unreasonable question. I wrote something on a whiteboard. What followed was the most surreal discussion I've had in an interview. My function took into account the seconds, minutes and hour for the hour hand, and so on. Just like a normal clock would. The interviewer ins…

I once interviewed with Boeing research and gave them the spiel about my PhD work on network protocols. They started asking me about Petri nets. I know nothing about Petri nets other than that they're another approach to distributed systems. I'm fairly sure I left them convinced I didn't understand my own research.

"Damn, that guy knows nothing! He hadn't the faintest idea of how fishing nets work!"

Re: I had to give a wrong answer to get the job (2017)

#408

Why would you want to work for a supervisor who is so prideful they can't stand the fact that there are other people who know more than them? Aside from needing an income of course.

Yeah well, that's a pretty big thing to put aside just like that, isn't it?

Re: I had to give a wrong answer to get the job (2017)

#409

Earlier quoted context omitted.

I’ve seen people go through the pipeline with “no hires” from interviewers because of small differences of opinion. In your case, I’d wager that the disagreeing interviewers feedback may have just been discarded.

They didn't fully clarify what kind of feedback the interviewer likely ended up giving in the end, though. I'd be curious to know if after they Googled it the interviewer acknowledged he was wrong and the interviewee was right. (I think they're kind of implying that, but it's unclear.)

Late but, for the record, I did get positive feedback from that interview, and the interviewer admitted his mental model was wrong.
Post reply on HN