AWT
AWT

Reputation: 381

iterative function - divide and conquer function

I'm just in the beginning of studying algorithm analysis and design course? and I just want to know: What's the difference between iterative function and divide and conquer function? Are they the same thing?

Upvotes: 1

Views: 1764

Answers (2)

smk
smk

Reputation: 5842

A divide and conquer algorithm will split the problem into smaller pieces and you solve the smaller pieces and then aggregate to get to the final solution.

An iterative algorithm is where you try to solve the entire problem by going over the entire problem.

This is by no means an authorative reply.

Thanks to blackbear for the suggestion.

Iterative example of Fibonacci series would be something like this

http://en.literateprograms.org/Fibonacci_numbers_(Scala)

And a divide and conquer method would be like this

def fibo(n:Int):Int = { if(n==1 || n==0) 1 else fibo(n-1) + fibo(n-2)}

Hope these examples add more clarity

Upvotes: 0

rai.skumar
rai.skumar

Reputation: 10677

Divide and conquer From wikipedia :

A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly.

Iterative function from Wikipedia :

In this process, starting from some initial number, the result of applying a given function is fed again in the function as input, and this process is repeated.

So they are not same

Upvotes: 2

Related Questions