O Running Time

Computer Science Level 2

Find the big-O running time of the following program that finds all lists with length equal to the length \(n\) of an input list \(l\) and elements only from the elements of the input list (the input list has no duplicate elements):

  • It has a list of lists \(A\) to return, which begins containing one empty list

  • It repeats the following steps \(n\) times

  • For each list \(m\) in \(A\), it adds \(n\) lists, the lists formed by adding each element of \(l\) to \(m\) (each of these will have one more element than \(m\)), to another list \(B\)

  • It assigns the value \(B\) to \(A\)


Problem Loading...

Note Loading...

Set Loading...