Live data from Hacker News

Inverting Binary Trees Considered Harmful

jasq.org

21–30 of 225 posts

Re: Inverting Binary Trees Considered Harmful

#21
post #13
post #9

What does it mean to invert a binary tree?

To change the nodes to point the other way around. So if the left edge of N1 points to N2 and the right edge points to N3 you make it so that N1's left edge points to N3 and the right edge points to N2. It's a trivial problem of changing pointers around. It's like 4 or 5 lines of code if you write a recursive function.

    def invert(node):
        if node is None: return
        invert(node.left)
        invert(node.right)
        node.left, node.right = node.right, node.left
Yep, pretty much. But, to be honest, if you hadn't described it I wouldn't have had a clue what was meant by inverting a tree. Zippering it or something? I wouldn't know.

Re: Inverting Binary Trees Considered Harmful

#22
post #11

Yeah 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 could have been herding goats there, maybe as part of some a green eco-initiative project...

Truth is stranger than fiction: http://googleblog.blogspot.sg/2009/05/mowing-with-goats.html

Re: Inverting Binary Trees Considered Harmful

#23
post #8

While I'm completely, 100%, against these kinds of questions, how else can a company that receives thousands of resumes a day filter out the good from bad?

It's actually not that hard -- invite them to work with you on a small project. Pay them reasonably. See how they work in RL. Then decide, and -- by all means -- give them honest feedback even when not hiring.

Re: Inverting Binary Trees Considered Harmful

#24
There's not so much a shortage of talented programmers as there is a shortage of people able to identify talented programmers.

If there's anything in need of serious disruption, it's the adversarial hiring process in technology. It's all mindless cargo-culting, and it doesn't actually work.

Re: Inverting Binary Trees Considered Harmful

#25
post #3

>You are then ushered into a room with the programmer's worst nightmare - a blank whiteboard. Am I the only one who enjoys programming interviews? Even if you screw it up, it's still fun to try your hand at whatever problem they give you. They also don't expect you to do it perfectly; you're allowed to have sub-superhuman performance.

It's not fun when you've sacrificed one of your finite vacation days to do it, and under the pressure of needing to find a new job.

Re: Inverting Binary Trees Considered Harmful

#26
Data counter-point: When I interviewed at Google, I used "echo foo" in my Java code through two white-board coding interviews, and I still got the job.

Sure, there are some terrible interviewers in the Valley (and I've been interviewed by some) but there are also some terrible interviewees (candidates?) out there.

Re: Inverting Binary Trees Considered Harmful

#27
A lot of these posts don't actually address the problem of hiring and filtering people. If you think whiteboard tests or logic puzzles are not effective, why do you think this and what is a better alternative?

I personally think they are ok, but should more be a means to test if the candidate can reason intelligently and it shouldn't matter much if the end answer they get is correct or not.

Re: Inverting Binary Trees Considered Harmful

#28

There's not so much a shortage of talented programmers as there is a shortage of people able to identify talented programmers. If there's anything in need of serious disruption, it's the adversarial hiring process in technology. It's all mindless cargo-culting, and it doesn't actually work.

> It's all mindless cargo-culting, and it doesn't actually work

amen.

Re: Inverting Binary Trees Considered Harmful

#29
post #23
post #8

While I'm completely, 100%, against these kinds of questions, how else can a company that receives thousands of resumes a day filter out the good from bad?

It's actually not that hard -- invite them to work with you on a small project. Pay them reasonably. See how they work in RL. Then decide, and -- by all means -- give them honest feedback even when not hiring.

I don't think that was the question, though. Small firms can afford to do this, but how does this scale to companies with who want to interview a few hundred candidates this month? Where do the hundreds of real-world projects come from?

Re: Inverting Binary Trees Considered Harmful

#30
i saw the thing on twitter earlier. what i don't get is why not ask the question of what that means? its such a simple problem once you know... and irl you don't know everything, if your interviewer expects it then you reject them for being a bad place to work.
Post reply on HN