Compared to an iterative approach, recursive divide and conquer is considerd what?
got_milk_biotch
2008-05-31 14:04:04 UTC
a is faster
b is simpler to implement
c has fewer steps
d better for simple problems
e none of the above
Four answers:
Donnie Murdo
2008-05-31 15:56:29 UTC
Thinking in terms of search algorithms an iterative approach could be a linear search and a divide and conquer approach could be a binary search. In this example, a divide and conquer approach could be considered a and c, in some but not all situations.
a - because a divide and conquer algorithm generally has a time complexity of o(log n^2) and an iterative approach has o(n)
b - divide and conquer halves the remaining data collection after each step and so will, in typcial cases, use fewer steps than an iterative approach
?
2016-12-31 11:00:44 UTC
A recursive physique of strategies will use greater reminiscence yet might take much less time, while an iterative physique of strategies makes use of much less reminiscence yet might take greater time. it particularly is fairly to obscure of a query. i assume you be conscious of what the two procedures are. in case you wrote an set of rules to sum the 1st a million million numbers, you does no longer % to apply a recursive function. when you consider which you will possibly create a million million cases of that function in the stack-physique / reminiscence. you will possibly % to apply an iterative loop. They the two might have a run time of massive Theta (N). in case you have been doing a binary seek of a million numbers, that's a log(n) run time, you should infact use a recursive function to discover the objective. it would take a max of 20 or so function calls. An iterative function might artwork a similar, however the code would be a splash greater complicated. in specific situations you may write a recursive function with 10 strains of code, that regularly might take 50 strains of code making use of an interative function. you basically might desire to be conscious of the impacts of making use of them. With present day-day computing reminiscence particularly isn't a subject, yet while the function takes an excellent chuck of reminiscence than calling the function recursively a million cases might crash your laptop (till you reboot)
brahle
2008-05-31 14:12:22 UTC
It always depends on a situation. But to me recursion with memoization usually comes more naturally.
It takes more memory because for every step you need to push new values onto stack. Thus you may risk stack overflow. Because of the constant pushing and popping onto stack, it is slower.
In most situations it has the same number of steps as the iterative approach.
Gazok
2008-05-31 14:12:24 UTC
D Better for simple problems. If you try it for complex problems you'll get LOTS of if statements all over the place, whereas a loop can acomplish a lot in a small space.
I guess it could also be simpler to implement, but D is the more correct answer.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.