[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Algorithms thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 32
Thread images: 11
File: Whiteboard_with_markers.jpg (146 KB, 1840x1123) Image search: [Google]
Whiteboard_with_markers.jpg
146 KB, 1840x1123
You have 30 seconds to invert a binary tree. Go.
>>
File: 1447990890055.jpg (143 KB, 1840x1123) Image search: [Google]
1447990890055.jpg
143 KB, 1840x1123
d-did i do it?
>>
File: 0.jpg (136 KB, 1840x1123) Image search: [Google]
0.jpg
136 KB, 1840x1123
rolling
>>
>>51430423
this is NSFW
>>
>>51430394
return 1/tree
>>
File: done.jpg (169 KB, 1840x1123) Image search: [Google]
done.jpg
169 KB, 1840x1123
>>51430394
>>
>>51430480
>binary tree
>>
>>51430480
Congrats. You got the job!
>>
>>51430487
>trinary bee
>>
File: beetree.png (55 KB, 640x400) Image search: [Google]
beetree.png
55 KB, 640x400
>>51430491
>>
>>51430467
no, it is a nose. a very jewish nose...
>>
>>51430394
Fuck this shit I'll just send a resume to Apple Inc. instead.
>>
File: 1439199406760.gif (368 KB, 380x298) Image search: [Google]
1439199406760.gif
368 KB, 380x298
>>51430594
best answer
>>
invert(node *root) {
if (*root != NULL) {
swap (root->left,root->right);
invert(node->right);
invert(node->left);
}
}

>b-but Google engineers use my code
>>
>>51430685
Who the fuck is that guy anyway?
>>
>>51430720
https://twitter.com/mxcl/status/608682016205344768
>>
>>51430394
(define (invert-tree tree)
(if (empty-tree? tree)
the-empty-tree
(make-tree (invert-tree (right-branch tree))
(invert-tree (left-branch tree)))))

Assuming binary trees are implemented, that is.
>>
>>51430725
I still don't get why it became such a big deal. Is he famous?
>>
>>51430759
>mess up the indentation
>the last words and parentheses line up
How serendipitous.
>>
>>51430781
That is just sad.
I'm not smart, I study Information Systems in a REALLY shit university in Brazil, we don't even study algorithms and I could solve that, first try.
>>
>>51430394
void invert(node* root){
if(*root != nullptr){
*root->setData(1/root->getData());
invert(root->getRight());
invert(root->getLeft());
}
}
>>
File: 1447990890055 - Copy.jpg (222 KB, 1840x1123) Image search: [Google]
1447990890055 - Copy.jpg
222 KB, 1840x1123
>>51430480
those aren't a tree
>>
>>51430835
Yeah, I get that, the guy is a retard. I just wasn't sure why everybody started talking about it. Apparently he is responsible for some MacOS package manager.
>>
File: invtree.jpg (241 KB, 1840x1123) Image search: [Google]
invtree.jpg
241 KB, 1840x1123
>>51430889
Step it up.
>>
>>51430904
...and tweetdeck and contributed to KDE in the early stages.
>>
File: 1447993317866.jpg (368 KB, 1840x1123) Image search: [Google]
1447993317866.jpg
368 KB, 1840x1123
>>51430889
>no binary
>>
>>51430784
the word right having more letters than the word left is serendipitous? how so?
>>
>>51430975
Interesting... Do you think he just didn't understand a question? Or maybe he was nervous?
>>
>>51431033
>he just didn't understand a question
I think this is the case. "Inverting a binary tree" is vague as fuck. It sounds like they want the tree turned upside-down or restructured in another way. Not just a simple left-right swap of every node's children.
>>
>>51431031
>make mistake
>still works out fine, in a sense
>>
File: 1375264300497.jpg (121 KB, 377x449) Image search: [Google]
1375264300497.jpg
121 KB, 377x449
>>51431055
Maybe that's what they were intending. To see if he would ask qualifying questions.
>>
File: ar13109851195143.jpg (457 KB, 800x600) Image search: [Google]
ar13109851195143.jpg
457 KB, 800x600
Thread replies: 32
Thread images: 11

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.