Mark As Completed Discussion

Try this exercise. Click the correct answer from the options.

Given this pseudo-code for the N combinations problem:

SNIPPET
1base case:
21. If all combinations starting with items in positions < (size-N) have been printed. Stop
3
4recursive case:
5Combos(set, result)
61. Repeat for each items i in the set:
7    a. Put the item i in the result set
8    b. if the result set has N items, display it
9        else
10        recursively call combos with (the input set without item i) and (the result set)
11    c. Remove the item i from result set

What should you change in the code above if all possible combinations of any size are to be displayed?

Click the option that best answers the question.

  • Change step a of Combos routine with N items in set
  • Change step b of Combos and display the set unconditionally
  • Remove step c of Combos
  • None of these options