tags:

views:

72

answers:

5

in regard to recursion what is a seed value?

+2  A: 

It seems to be the value that you initially pass into the function:

For example here: http://www.ibm.com/developerworks/linux/library/l-recurs.html

Every recursive program follows the same basic sequence of steps:

  1. Initialize the algorithm. Recursive programs often need a seed value to start with. This is accomplished either by using a parameter passed to the function or by providing a gateway function that is nonrecursive but that sets up the seed values for the recursive calculation.
  2. Check to see whether the current value(s) being processed match the base case. If so, process and return the value.
  3. Redefine the answer in terms of a smaller or simpler sub-problem or sub-problems.
  4. Run the algorithm on the sub-problem.
  5. Combine the results in the formulation of the answer.
  6. Return the results.

If you have a function f(n) then a base case is a parameter n which doesn't result in a recursive call to f.

Mark Byers
I would call that a base case. I think everyone else here is correct in stating that the seed value would be the initial argument passed in to the recursive function.
Jonathan
Agreed... I was wrong before.
Mark Byers
A: 

A seed value would be the data that you are passing into the function. This doesn't always apply to recursion and is not a common term. Keep in mind that the seed value must pass the base case.

Rook
what is a base case?
David
A base case is usually the first check a recursive function makes. This check is responsible for stopping recursion because the work has completed.
Rook
A: 

A seed identifies the starting point of the search.

Scott Smith
+5  A: 

Many recursive algorithms perform some kind of calculation/transformation based on the results of a previous recursive call to the algorithm. The seed value would be the value passed in to the initial call to the recursive algorithm.

For example if you were writing a recursive algorithm to enumerate all the elements of a tree structure, the seed might be the root node of the tree.

Eric Petroelje
A: 

Hi

Seed value in terms of a recursive program or function would mean the initial value assigned to the parameter(s) of that program or function. These parameters would be used in each of the subsequent recursive calls to that program/function.

cheers

Andriyev