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.
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.
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbe5d5f71-3ad7-4161-bd6e-fd06ac1f44bb%2Fc30ec853-d4cc-4f2e-b1a9-021994734472%2Fsn8v7tt_processed.png&w=3840&q=75)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
