4 ms·
I don't fully get this argument. Trees are a very common thing to encounter in all sorts of programming and recursively walking them is also very common. I had
by thu2111 6y ago
I don't fully get this argument. Trees are a very common thing to encounter in all sorts of programming and recursively walking them is also very common. I had to do it yesterday as part of writing some code to traverse a file system, nothing fancy.
Although I've never asked or been asked it in interview context, reversing a binary tree specifically is probably just checking you understand how to write recursive functions. Binary, because variable number of child nodes would make the code longer and more complex for no good reason. Reverse, because that's the simplest operation you can do at each node.
People in this thread are acting like tree processing is as exotic as theorem proving, and could never have anything imaginable to do with daily work, but every web page is literally a tree!
- BoorishBears 6y agoTime complexity often comes up in these problems too, so it's not enough to just know the requisite parts of the problem you need to have memorized specific approaches unless you plan on doing some theory crafting mid interview... And it's not like you can't find out of the applicant knows recursion and what a tree is without bringing in memorization, there's just some weird obsession with a very specific type of problem which happens to often involve memorization
- cutemonster 6y agoAgreed that tree algos are common, there's some in an app I'm building. And time complexity trade-offs too.