Question: Given the set S = { 1, 2, 3, 4, 5, 6 }. Write an algorithm that prints out all the subsets of three elements
Given the set S = { 1, 2, 3, 4, 5, 6 }. Write an algorithm that prints out all the subsets of three elements of a set of n elements. The elements of this set are stored in a list that is the input to the algorithm.
I don't need help writing the algorithm, however; I am confused by the wording. Does it mean first take { 1, 2, 3 } as a subset of "S" then find all combinations of this subset e.g. { 1, 2, 3}, { 1, 3, 2}, { 2, 1, 3 }, { 3, 1, 2 }, { 2, 3, 1}, { 3, 2, 1 }..... and continue until all subsets of three have been reached? If you could please show and explain the pattern that would be great! Thanks in advance!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
