{"id":117,"date":"2015-01-16T19:00:17","date_gmt":"2015-01-17T02:00:17","guid":{"rendered":"https:\/\/blogs.ubc.ca\/cpsc320\/?p=117"},"modified":"2015-01-16T19:00:17","modified_gmt":"2015-01-17T02:00:17","slug":"tutorial-2-problems","status":"publish","type":"post","link":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/2015\/01\/16\/tutorial-2-problems\/","title":{"rendered":"Tutorial #2 Problems"},"content":{"rendered":"<ol>\n<li>Rank the following functions by order of growth. That is, order them so that f<sub>1<\/sub> \u2208 O(f<sub>2<\/sub>), f<sub>2<\/sub> \u2208 O(f<sub>3<\/sub>), etc. Make sure to indicate whether or not f<sub>i<\/sub> \u2208 \u0398(f<sub>i+1<\/sub>). For instance you could use the notation <tt>O(n) \u2282 O(n^2) = O(2n^2) \u2282 O(n^4)...<\/tt><br \/>\n<table border=\"3\">\n<tbody>\n<tr>\n<td width=\"140\">n<sup>3<\/sup> &#8211; n <span>\u221a<span style=\"text-decoration: overline\">\u00a0n\u00a0<\/span><br \/>\n<\/span><\/td>\n<td>n!<\/td>\n<td>log (log n)<\/td>\n<td>1.01<sup>n<\/sup><\/td>\n<\/tr>\n<tr>\n<td width=\"140\"><span>\u221a<span style=\"text-decoration: overline\">\u00a0n log n\u00a0<\/span><br \/>\n<\/span><\/td>\n<td>17<\/td>\n<td>4913n<sup>289<\/sup><\/td>\n<td>3<sup>2n-17<\/sup><\/td>\n<\/tr>\n<tr>\n<td width=\"140\">1.01<sup>1.01<sup>n<\/sup><\/sup><\/td>\n<td><span>\u221a<span style=\"text-decoration: overline\">\u00a0n\u00a0<\/span><br \/>\n<\/span><\/td>\n<td>3<sup>n<\/sup><\/td>\n<td>n<sup>n<\/sup><\/td>\n<\/tr>\n<tr>\n<td width=\"140\">n<sup>18\/17<\/sup><\/td>\n<td>n log<sup>17<\/sup> n<\/td>\n<td>3<sup>2n<\/sup><\/td>\n<td>n<sup>3<\/sup> + log n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>Prove that for each <b>fixed<\/b> value of <i>k<\/i> &gt; 0, <i>1<sup>k<\/sup> +\u00a02<sup>k<\/sup> + &#8230; + (t-1)<sup>k<\/sup> + t<sup>k<\/sup> \u2208\u00a0\u0398(t<sup>k+1<\/sup>)<\/i>. Hint: do not use induction. Instead, treat <i>k\u00a0<\/i>as a constant, and do <i>O<\/i> and <i>\u03a9<\/i> separately. (Remember that for\u00a0<i>\u03a9<\/i> bounds, it is legal to drop positive terms and reduce the size of positive terms, since you can guarantee that the resulting function is still a lower bound on the original.)<\/li>\n<li>Analyze the running time of the following algorithm as a function of n,\u00a0assuming that each arithmetic operation takes constant time. Use O, \u03a9 or\u00a0\u0398 notation as appropriate to express your result as simply and as precisely as\u00a0possible. Give an informal argument (not necessarily a full proof) to support your\u00a0answer. (It may help to think about the &#8220;measure of progress&#8221; approach the book used to analyze the while loop in the Gale-Shapley Algorithm.)\n<pre>Algorithm Strange(n)\n    sum \u2190 0\n    while (n &gt; 3) do\n        sum \u2190 sum + n\n        if (n is even) then\n            n \u2190 n \/ 2\n        else\n            n \u2190 n + 3\n        endif\n    return sum\n<\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Rank the following functions by order of growth. That is, order them so that f1 \u2208 O(f2), f2 \u2208 O(f3), etc. Make sure to indicate whether or not fi \u2208 \u0398(fi+1). For instance you could use the notation O(n) \u2282 O(n^2) = O(2n^2) \u2282 O(n^4)&#8230; n3 &#8211; n \u221a\u00a0n\u00a0 n! log (log n) 1.01n \u221a\u00a0n [&hellip;]<\/p>\n","protected":false},"author":7560,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3426],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/users\/7560"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ubc.ca\/cpsc3202014w2\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}