0

I am trying to understand the time and space complexity of this method. I read the following post which attempts to explain recursive time/space complexity. Inspite of that I am still not sure how I would start determining the space and time complexity of this problem.

std::vector<std::vector<int>> fresult;
void findSum(int index,int target, std::vector<int> originals,std::vector<int>  possiblities)
{
    if (index == originals.size())
    {
        //Check if the target has been met
        if (target == 0)
        {
            fresult.push_back(possiblities);
        }
        return;
    }
    
    if (originals[index] <= target)
    {
        possiblities.push_back(a);
        findSum(index, target - originals[index], originals, possiblities);
        possiblities.pop_back();
    }
    findSum(++index, target, originals, possiblities);
}

Any suggestions on how I can determine time/space complexity of this problem

James Franco
  • 4,516
  • 10
  • 38
  • 80
  • See if you can use this in addition to answers below: https://visualgo.net/en/recursion –  Jul 02 '21 at 23:49
  • This is particularly for recursion https://stackoverflow.com/questions/13467674/determining-complexity-for-recursive-functions-big-o-notation – iwrestledthebeartwice Jul 03 '21 at 04:18

0 Answers0