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.
Only for first 4 functions. I believe it should be linear, linear, linear and quadratic
i can show you mine if you'ld like. or you could use a code pasting site to post yours for comment. There are solutions from individuals (students) available online - I think if you google MIT OCW ps7 or pset 7.... you would find them. There are no 'official' solutions for the 2008 course. Some of the 2008 topics are in the 2011 course and there are solutions for the 2011 course - but the pset numbers don't match up.
Which one is pset 7?
It is pset7 from 2008. You only need to determine the rate of growth for the first 4 functions. As i said I got linear, linear, linear and quadratic for the forth. However, I found answers on the web which says that all of them are linear. I have attached the PDF file of the assignment. I would need confirmation/explanation for the 4th function.
Why quadratic for the fourth function? My logic is that to make s1 it takes linear time and then we have to loop through each element in s1 so it is again linear. Two linear times should give quadratic.
Not the answer you are looking for? Search for more explanations.
you would think 4 is n-squared but maybe because s1 and s2 can change independently then it is linear s1 --> O(len(s1)) or linear with s2 --> O(len(s2)
when you change s1 s2 doesn't have to change and vice versa. so it is not the same as
for i in xrange(n):
for j in xrange(n)
which would be O(n-squared)
check out the set intersection complexity here : http://wiki.python.org/moin/TimeComplexity
you end up getting a scaling effect, not an exponential effect -
if len(s2) is four then for len(s1) = 1-4 you get
4, 8, 12, 16 inner loops which is linear
same thing if you vary s2 length and hold s1 constant
Thank you, I corrected my answer, because I saw my silly mistake. Could you have a quick look at the attachment? I might still be wrong.
pretty sure this statement is incorrect:
'...it searches through the string s2 using hashing..."
the in operator is linear for a sequence. strings are sequence data types. Python does not use hash tables to find things in sequences