Write a recursive method called subsets to find every possible sub-lis
Write a recursive method called subsets to find every possible sub-list
of a given list. A sub-list of a list L contains 0 or more of L's elements.
Your method should accept a list of strings as its parameter and print
every sub-list that could be created from elements of that list, one per
line. For example, if the list stores [Janet, Robert, Morgan, Char],
the output from your method would be:
[Janet, Robert, Morgan, Char]
[Janet, Robert, Morgan]
[Janet, Robert, Char]
[Janet, Robert]
[Janet, Morgan, Char]
[Janet, Morgan]
[Janet, Char]
[Janet]
[Robert, Morgan, Char]
[Robert, Morgan]
[Robert, Char]
[Robert]
[Morgan, Char]
[Morgan]
[Char]
[]
The order in which you show the sub-lists does not matter, and the order
of the elements of each sub-list also does not matter. The key thing is
that your method should produce the correct overall set of sub-lists as its
output. Notice that the empty list is considered one of these sub-lists.
You may assume that the list passed to your method is not null and that
the list contains no duplicates. Do not use any loops.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.
