anonymous
  • anonymous
does anyone have the answers to ps7?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
what's the problem
anonymous
  • anonymous
6.00 Problem Set 7 Out: Friday, October 17 Due: Tuesday, October 21 This problem set is designed to help you solidify your understanding of some material that we have covered in lecture, but not emphasized on the programming problems. You should do it, but do NOT hand it in. 1) What is the computational complexity of fact0? Explain your answer. def fact0(i): assert type(i) == int and i >= 0 if i == 0 or i == 1: return 1 return i * fact0(i-1) 2) What is the computational complexity of fact1? Explain your answer. def fact1(i): assert type(i) == int and i >= 0 res = 1 while i > 1: res = res * i i -= 1 return res 3) What is the computational complexity of makeSet? Explain your answer. def makeSet(s): assert type(s) == str res = '' for c in s: if not c in res: res = res + c return res 4) What is the computational complexity of intersect? Explain your answer. def intersect(s1, s2): assert type(s1) == str and type(s2) == str s1 = makeSet(s1) s2 = makeSet(s2) res = '' for e in s1: if e in s2: res = res + e return res 5) Present a hand simulation of the code below. Describe the value to which each identifier is bound after each step of the computation. Note that “s1” and “s2” exist in more than one scope. def swap0(s1, s2): assert type(s1) == list and type(s2) == list tmp = s1[:] s1 = s2[:] s2 = tmp return s1 = [1] s2 = [2] swap0(s1, s2) print s1, s2 6) Present a hand simulation of the following code: def swap1(s1, s2): assert type(s1) == list and type(s2) == list return s2, s1 s1 = [1] s2 = [2] s1, s2 = swap1(s1, s2) print s1, s2 7) Present a hand simulation of the following code: def rev(s): assert type(s) == list for i in range(len(s)/2): tmp = s[i] s[i] = s[-(i+1)] s[-(i+1)] = tmp s = [1,2,3] rev(s) print s
anonymous
  • anonymous
Here is a link if you want to see the answers: http://mit.edu/magnus89/Public/Classes/6.00%20F08/Pset%207%20Soln.pdf

Looking for something else?

Not the answer you are looking for? Search for more explanations.