In his programming class, Rishabh is asked to implement a program that takes in a set of distinct integers and output all possible subsets of .
However, the catch is that he is asked not to use recursive functions.
Using which data structure makes more sense for Rishabh to solve this problem?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The natural way to answer this problem is this:
Since function calls themselves are implemented within the memory using a stack, it is possible to use stacks to implement the behaviour of recursion.