I'll be the contrarian and claim that inverting a binary tree is a perfectly reasonable interview question. (Although not anymore now that it's famous). It combines basic background knowledge (what is a binary tree and how is it structured?), ability to reason logically (binary tree algorithms are often recursive, "inverting" a tree with no children is a no-op, otherwise you want to swap the children, and the childre…
> I'll be the contrarian and claim that inverting a binary tree is a perfectly reasonable interview question. The fact that so many people in the previous discussion could not even tell what that means is a very bad sign.
Inverting Binary Trees Considered Harmful
211–220 of 225 posts
Re: Inverting Binary Trees Considered Harmful
#212Yeah I remember the Google interview a few years back. I did it mostly for fun, and because their recruiters kept contacting me. So there we were, building a tree out of a forest of existing smaller trees or such. That was after they couldn't find my resume, and used a 5 year old one they found some place. They seemed annoyed and tired. By that time I felt nothing short of me proving P!=NP would have help changed the…
I was told by someone many years ago to always take a copy of my resume with me to an interview. That advice has paid off a couple of times. These days I also keep an email draft ready to send.
Re: Inverting Binary Trees Considered Harmful
#213Earlier quoted context omitted.
Most posts complaining about interview process are being made by people who failed those interviews. There is a ton of reverse-survivorship bias here. It's certainly not the case that companies like GOOG/FB/MS are filled with all bozzos. If anything their interview process have been rather successful considering above average quality of talent at these companies and non-trivial products they work on. I also sense lot…
>As a programmers we are supposed to be loving these kind of CS puzzles. I want in implementation of a high performance octree. Do it for me. Apparently you love doing this sort of thing for people who don't pay you.
Re: Inverting Binary Trees Considered Harmful
#214The last interview I did was for a node.js position. I was told to bring my laptop. When I got there, the put me in an office and handed me a packet with instructions on checking out a nearly empty git repo. Then they said "Write an API that meets as many of the following requirements as possible and push the code. We'll be back in 3 hours." After 3 hours, I was taken to a conference room where I demonstrated the API…
Hearing someone talk about their own code and explain their approach and the up and down sides of it, is a lot more valuable than simply having the correct answer roll out.
Re: Inverting Binary Trees Considered Harmful
#215I'm more than happy to participate in a technical interview and I always prepare the best I can. However, I find it odd that technical interviews don't work both ways. The interviewer can ask you to solve problem x, but if you ask the interviewer to solve problem y (fair play, right?) I suspect you would be shown the door. Interviewer: "Can you show me on the whiteboard how you would invert a binary tree?" You: "Of c…
wow, that's a great idea. I would love that interview. In addition, they should solve a problem with an engineer that would be their junior and their senior, to show how they contribute to those situations.
Re: Inverting Binary Trees Considered Harmful
#216Earlier quoted context omitted.
Most posts complaining about interview process are being made by people who failed those interviews. There is a ton of reverse-survivorship bias here. It's certainly not the case that companies like GOOG/FB/MS are filled with all bozzos. If anything their interview process have been rather successful considering above average quality of talent at these companies and non-trivial products they work on. I also sense lot…
>As a programmers we are supposed to be loving these kind of CS puzzles. I want in implementation of a high performance octree. Do it for me. Apparently you love doing this sort of thing for people who don't pay you.
Re: Inverting Binary Trees Considered Harmful
#217Earlier quoted context omitted.
>As a programmers we are supposed to be loving these kind of CS puzzles. I want in implementation of a high performance octree. Do it for me. Apparently you love doing this sort of thing for people who don't pay you.
Are you offering a job?
Re: Inverting Binary Trees Considered Harmful
#218Earlier quoted context omitted.
To fill in one gap - our hiring process has an extra layer of insulation to better control individual biases. Your interviewers all submit feedback and an independent hiring committee makes the decision, on a different day, with all due deliberation. The reason nobody has anything to say to you at the end of the day is because none of that has happened so nobody knows what to say at that point, and I don't think it's…
Yes, "thousands of Google engineers who do interviews haven't figured out that people writing code on a whiteboard under stress aren't the same thing as people sat at their desk grinding out code?" I am pretty confident they don't know that. I know people way smarter than me who flunked the google interviews and, working in the same building, know even more that got in who are very good but not great. Also, they are…
https://www.google.com/about/careers/lifeatgoogle/hiringproc... is a pretty good explanation.
Re: Inverting Binary Trees Considered Harmful
#219Earlier quoted context omitted.
I'm still not entirely sure what that means. Does it mean you recursively swap left and right branches, or does it mean you create a new data structure where the bottom elements become the top elements?
Apparently it means to swap the left and right subtrees. How's that "inversion"? I'd call it "flipping" or "mirroring" or something... If this is the case, then it's a trivial solution: invert(left_child); invert(right_child);
struct node {
struct node *left_node;
struct node *right_node;
int val;
};
struct reversed_node {
struct reversed_node *right_node;
struct reversed_node *left_node;
int val;
};
No? You then just have a different mapping for the exact same data, no traversal needed.Re: Inverting Binary Trees Considered Harmful
#220Earlier quoted context omitted.
Yes, "thousands of Google engineers who do interviews haven't figured out that people writing code on a whiteboard under stress aren't the same thing as people sat at their desk grinding out code?" I am pretty confident they don't know that. I know people way smarter than me who flunked the google interviews and, working in the same building, know even more that got in who are very good but not great. Also, they are…
Here's an alternative hypothesis: the interview process is selecting for different traits than what you are expecting. https://www.google.com/about/careers/lifeatgoogle/hiringproc... is a pretty good explanation.