Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,352,953 members, 5,218,655 topics. Date: Sunday, 20 October 2019 at 01:00 PM

Programming Interview Question: Invert A Binary Tree - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Programming Interview Question: Invert A Binary Tree (765 Views) (2) (3) (4)

(1) (Reply) (Go Down)

Programming Interview Question: Invert A Binary Tree by project7(m): 7:40am On Oct 19, 2016
Reflecting on a tweet by Max Howell:

Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fvck off.

So in your language of choice how do you invert a Binary Tree.

For example:
This
1
/ \
2 3
/ \ \
4 5 6

To this
4 5 6
\ / /
2 3
\ /
1
Re: Programming Interview Question: Invert A Binary Tree by paranorman(m): 8:38am On Oct 19, 2016
project7:
Reflecting on a tweet by Max Howell:

Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fvck off.

So in you language of choice how do you invert a Binary Tree.

For example:
This
1
/ \
2 3
/ \ \
4 5 6

To this
4 5 6
\ / /
2 3
\ /
1
I don't even understand.
Re: Programming Interview Question: Invert A Binary Tree by SeunLanLege(m): 9:27am On Oct 19, 2016
project7:
Reflecting on a tweet by Max Howell:

Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fvck off.

So in you language of choice how do you invert a Binary Tree.

For example:
This
1
/ \
2 3
/ \ \
4 5 6

To this
4 5 6
\ / /
2 3
\ /
1

[size=19pt]Javascript [/size]


var tree = function(root) {
if (!root)
return null;
tree(root.left);
tree(root.right);
x = root.left;
root.left = root.right;
root.right = x;

return root;
};

Simple and easy

1 Like

Re: Programming Interview Question: Invert A Binary Tree by asalimpo(m): 10:05am On Oct 19, 2016
crap. Does he invert binary trees in his "day job"?
Did he invert binary tree when creating home brew?
These interviewers just pull questions out of their ass and fling them at interviewees.

1 Like

Re: Programming Interview Question: Invert A Binary Tree by sharrp: 2:05pm On Oct 19, 2016
asalimpo:
crap. Does he invert binary trees in his "day job"?
Did he invert binary tree when creating home brew?
These interviewers just pull questions out of their ass and fling them at interviewees.
You get the whole point of that wrong. Yes the interview process is flawed. But a company like google is always about scaling and efficiency. Knowing when to use an array or a binary search tree really has a lot of payoff for a company like google. 70% of google engineers maintain and refactor code bases but their is 30% that takes on a new project aimed at millions of users. Knowing the right data structures to use helps a lot. And that dude was not rejected because he coundt invert a binary tree. Failing one question doesn't spell doom for a google interview
Re: Programming Interview Question: Invert A Binary Tree by sharrp: 2:06pm On Oct 19, 2016
SeunLanLege:


[size=19pt]Javascript [/size]


var tree = function(root) {
if (!root)
return null;
tree(root.left);
tree(root.right);
x = root.left;
root.left = root.right;
root.right = x;

return root;
};

Simple and easy
When you copy a code online ,understand it. This does not invert a binary tree.

1 Like

Re: Programming Interview Question: Invert A Binary Tree by SeunLanLege(m): 2:35pm On Oct 19, 2016
sharrp:

When you copy a code online ,understand it. This does not invert a binary tree.

Really? Then enlighten us, oh great one.

Oh and point links to where I copied the code. . When making accusations provide proof or you'll make yourself look immature.
Re: Programming Interview Question: Invert A Binary Tree by silento(m): 3:35pm On Oct 19, 2016
google did that to mock the guy

they even said Bleep u nvidia
Re: Programming Interview Question: Invert A Binary Tree by ultmatmus(m): 8:34pm On Oct 19, 2016
SeunLanLege:


Really? Then enlighten us, oh great one.

Oh and point links to where I copied the code. . When making accusations provide proof or you'll make yourself look immature.
I know you... i saw you at that microsoft aiki program at funaab today

(1) (Reply)

Need A Php Web Developer In Porthacourt For A Binary Mlm Script / I Need A Binary MLM Script / Pls I Need Interview Question For AI Sweigart

. / Whatsapp Group For Webmasters Join Now Link Below Or Drop Ur Whsapp No: / Anyone Working With Sap In Here

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2019 Oluwaseun Osewa. All rights reserved. See How To Advertise. 46
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.