News for hackers. Stuff that matters.
Re:How to hire engineering talent without the BS by dekhn on Sunday March 05, 2023 @12:52PM (#35032042)
Wouldn't that be a "mirror" operation, while inversion would be (I dunno) swapping the direction of the edges?

I went out of my way to avoid homebrew (still do) when I worked at google because it would reliably fail to complete some key operations in a dag, hence the interest in ensuring developers know how to do CS things.

Re:How to hire engineering talent without the BS by howling on Sunday March 05, 2023 @01:00PM (#35032133)
Yeah it's not clear what he was asked. Swapping the direction of every edge of a binary tree would result in a DAG that is likely no longer a binary tree though.
Re:How to hire engineering talent without the BS by gifnamething on Sunday March 05, 2023 @07:20PM (#35035852)
Are you confusing a binary tree with something else?

Here's an example:

https://leetcode.com/problems/invert-binary-tree/

It's an 'easy' question. The solution is <10 lines.

Re:How to hire engineering talent without the BS by zeroonetwothree on Sunday March 05, 2023 @09:46PM (#35036955)
Yeah it's really easy. I wrote a correct solution in about 30 seconds on my first try. And I haven't actually practiced these problems for 10+ years.
Re:How to hire engineering talent without the BS by virtuous_signal on Sunday March 05, 2023 @01:03PM (#35032179)
"Mirror" is what this question is generally understood to be asking. I don't think swapping the direction of the edges produces a tree in general although it would produce a DAG. I think "invert" could mean "mirror" or turn upside-down depending on the context.
Re:How to hire engineering talent without the BS by dekhn on Sunday March 05, 2023 @01:09PM (#35032256)
Personally, if I were asked this, I would just say "convert the graph to a matrix, invert the matrix, and then convert the resulting inverted matrix back to a graph", and let them try to figure out if that would work for a bit before joking "oh come on, preorder traversal with a temp var, do you have a more interesting question?"
Re:How to hire engineering talent without the BS by karmakaze on Sunday March 05, 2023 @01:13PM (#35032285)
It would be more leetcode to be given an ordered binary tree and asked to reverse it O(N). It's a lot more fair to the interviewee to be given the explicit task without knowing 'the trick' unless one considers knowing recursive functions to be a trick.
Re:How to hire engineering talent without the BS by sophonX on Sunday March 05, 2023 @12:54PM (#35032079)
There you go ! This comment should be highlighted.
Re:How to hire engineering talent without the BS by devnullbrain on Monday March 06, 2023 @07:36AM (#35040259)
It doesn't matter, the candidate should ask for clarification if the question is ambiguous.
Re:How to hire engineering talent without the BS by sophonX on Monday March 06, 2023 @01:56PM (#35045856)
I was referring to second para or statement. (-_-)