Task 1. Peter Zmeda has found the following function 1 def Vars (prefix, n): 2 34 56 7 if n == 0: print (prefix) else: for ch in ['A', 'C', 'G', 'T']: new prefix + ' ' + ch Vars (new, n-1) that should print all variations with repetitions of a given length.

icon
Related questions
Question

Questions:

1.Write down the first 7 lines that are printed after calling Vars("22", 3).

2.(i) Write down the recursive formula for calculating the time complexity as
function of n and justify the answer. (ii) What is the time complexity of the
function Vars? Justify your answer. 

3.Show that the function Vars("", n) indeed prints out all variations with
repetitions of length n over the set {A, C, T, G} .
HINT: What is often good to use in order to prove the correctness of a recursive
algorithm?

Task 1. Peter Zmeda has found the following function
1
def Vars (prefix, n):
2
34
56
7
if n == 0:
print (prefix)
else:
for ch in ['A', 'C', 'G', 'T']:
new prefix + ' ' + ch
Vars (new, n-1)
that should print all variations with repetitions of a given length.
Transcribed Image Text:Task 1. Peter Zmeda has found the following function 1 def Vars (prefix, n): 2 34 56 7 if n == 0: print (prefix) else: for ch in ['A', 'C', 'G', 'T']: new prefix + ' ' + ch Vars (new, n-1) that should print all variations with repetitions of a given length.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer