Live data from Hacker News

Dynamic Programming vs. Divide-and-Conquer (2018)

trekhleb.dev

11–20 of 120 posts

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#11
post #3

I think that what the author calls "divide and conquer" is actually "recursion". Also the complexity of naive fibonacci is exactly the fibonacci sequence so O(2^n) is correct but less precise than O(phi^n)

"Recursion" is part of the "how" of the "why" of "divide and conquer" :P

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#12
post #3

I think that what the author calls "divide and conquer" is actually "recursion". Also the complexity of naive fibonacci is exactly the fibonacci sequence so O(2^n) is correct but less precise than O(phi^n)

Recursion is not the same as divide and conquer. Divide and conquer is a category of algorithms that you would often implement with recursion, but you don't have to.

For example, consider the bottom-up implementation of merge sort [1]. This implementation is not recursive, but merge sort uses divide and conquer regardless of whether or not you implement it top-down or bottom-up.

On the other hand, the naive fibonacci implementation that runs in exponential type is recursive, but it does not use divide and conquer.

[1]: https://en.wikipedia.org/wiki/Merge_sort#Bottom-up_implement...

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#13
post #2

The ratio of importance placed on these algorithm design in interviews vs the amount of times they actually come up in real world problems seems skewed IMO.

I would argue that it's a pretty good measure of programming and CS problem solving skill with weak alternatives.

Most of these types of algorithms already have tons of research available online as people try to figure out what the lower bound of optimization is. It's far more telling to just talk about previous projects the person has worked on to gauge their level of competence. Asking them to explain why they made the choice they did vs trying to see how much they can memorize tests two different skill sets. The person who makes better choices is the one you want to hire.

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#14
post #2

The ratio of importance placed on these algorithm design in interviews vs the amount of times they actually come up in real world problems seems skewed IMO.

Yeah, interviews should really be asking more questions about graph algorithms instead. Those are so much more useful.

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#16
post #3

I think that what the author calls "divide and conquer" is actually "recursion". Also the complexity of naive fibonacci is exactly the fibonacci sequence so O(2^n) is correct but less precise than O(phi^n)

All recursion can be translated into a loop and a stack. In the tail recursive case you don’t even need a stack, a loop would suffice.

That means all divide and conquer algorithms can be implemented without recursion.

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#17
post #13

Earlier quoted context omitted.

I would argue that it's a pretty good measure of programming and CS problem solving skill with weak alternatives.

Most of these types of algorithms already have tons of research available online as people try to figure out what the lower bound of optimization is. It's far more telling to just talk about previous projects the person has worked on to gauge their level of competence. Asking them to explain why they made the choice they did vs trying to see how much they can memorize tests two different skill sets. The person who ma…

How does someone talking tell you if they can actually do basic programming... I think you would be surprised at the number of people that apply for software engineering jobs but barely know how to program.

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#18
post #13

Earlier quoted context omitted.

Most of these types of algorithms already have tons of research available online as people try to figure out what the lower bound of optimization is. It's far more telling to just talk about previous projects the person has worked on to gauge their level of competence. Asking them to explain why they made the choice they did vs trying to see how much they can memorize tests two different skill sets. The person who ma…

How does someone talking tell you if they can actually do basic programming... I think you would be surprised at the number of people that apply for software engineering jobs but barely know how to program.

To be fair, I know a fair number of people who are good at competitive programming but are absolutely awful at writing maintainable code.

Re: Dynamic Programming vs. Divide-and-Conquer (2018)

#19

Earlier quoted context omitted.

How does someone talking tell you if they can actually do basic programming... I think you would be surprised at the number of people that apply for software engineering jobs but barely know how to program.

To be fair, I know a fair number of people who are good at competitive programming but are absolutely awful at writing maintainable code.

Yeah, competitive programming forces you to use short variable names and write makeshift code which is fast enough to pass all the test cases ...
Post reply on HN