Question: Do not import any package. Write a recursive function that takes a list of positive integers (nums, not empty) and a positive integer target, and

 Do not import any package. Write a recursive function that takes

Do not import any package.

Write a recursive function that takes a list of positive integers (nums, not empty) and a positive integer target, and find whether it's possible to pick a combination of integers from nums, such that their sum equals the target. Return True if we can pick such a combination of numbers from nums; otherwise, return false. Hints: (1) For each recursive call, you should only deal with one number in the list. Think about how to approach these sub-problems with recursion: if we include this number in the combination, can we reach the target sum? How about excluding this number from the combination? (2) Although we assume that the initial arguments are positive integers and the initial nums list is not empty, you might observe that, at some point, a recursive call will receive arguments that violate these assumptions (for example, the nums list becomes empty). You might find it helpful to treat these situations as base cases. Examples: nums target output [3, 34, 4, 12, 5, 2] 9 True [1, 1, 1] 9 False [1, 10, 9, 8] 17 True

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!