Lab09 solutions (UCB CS61A@2021 Fall)
Recursion and Tree Recursion
Q1: Subsequences
A subsequence of a sequence
S
is a subset of elements fromS
, in the same order they appear inS
. Consider the list[1, 2, 3]
. Here are a few of it’s subsequences[]
,[1, 3]
,[2]
, and[1, 2, 3]
.Write a function that takes in a list and returns all possible subsequences of that list. The subsequences should be returned as a list of lists, where each nested list is a subsequence of the original input.