struct EuropeanPut
{
  bool pathDependent;

  void derivativeInit(unsigned int N)
  {
    pathDependent = false;

    return;
  }

  void visitStock(unsigned int depth, unsigned int c, double inStockValue)
  {
    return;
  }

  double payOff(double K, double inStockValue)
  {
    // printf("payOff: %f\n", MAX(0.0, inStockValue - K));

    return MAX(0.0, K - inStockValue);
  }

  double derivativeValue(stack<double> *childStack, unsigned int T, vector< vector<double> > P, 
			 vector<double> disc, double unused1, double unused2)
  {
    int pindex;                     // index into first vector of P
                                   // needed because P might be time dependent or time independent

    if(P.size() > 1)     // is P time dependent?
      pindex = T;
    else
      pindex = 0;
    
    double derivativeValue = 0.0;

    for(int childNum = P[pindex].size() - 1; childNum >= 0; childNum--)
      {
	derivativeValue += childStack->top() * P[pindex][childNum];
	
	//printf("childStack->top is %f, result is %f (%f * %f)\n", childStack->top(), derivativeValue, 
	//     childStack->top(), P[pindex][childNum]);

	childStack->pop();
      }
    
    double r;
    
    if(disc.size() > 1)   // is R time dependent?
      r = disc[T];
    else
      r = disc[0];
    
    return r * derivativeValue;
  }
};
