{"id":5214,"date":"2017-02-03T04:00:49","date_gmt":"2017-02-03T04:00:49","guid":{"rendered":"https:\/\/assignment.essayshark.com\/blog\/?p=5214"},"modified":"2022-01-12T12:41:57","modified_gmt":"2022-01-12T12:41:57","slug":"sample-assignments-the-one-on-recursive-functions","status":"publish","type":"post","link":"https:\/\/assignmentshark.com\/blog\/sample-assignments-the-one-on-recursive-functions\/","title":{"rendered":"Sample Assignments: The One on Recursive Functions"},"content":{"rendered":"<p>Task:<\/p>\n<p>Find the function of the Ackerman fuction A(m, n), using the recurrence relations:<\/p>\n<p class=\"formula\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/ql-cache\/quicklatex.com-4e98c286a9c9f290f61b6fc1fc3d568e_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#92;&#108;&#101;&#102;&#116;&#92;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#65;&#40;&#48;&#44;&#32;&#110;&#41;&#32;&#61;&#32;&#110;&#32;&#43;&#32;&#49;&#44; &#92;&#92;&#32;&#65;&#40;&#109;&#44;&#32;&#48;&#41;&#32;&#61;&#32;&#65;&#40;&#109;&#32;&#45;&#32;&#49;&#44;&#32;&#49;&#41;&#44; &#92;&#92;&#32;&#65;&#40;&#109;&#44;&#110;&#41;&#32;&#61;&#32;&#65;&#40;&#109;&#32;&#45;&#32;&#49;&#44;&#65;&#40;&#109;&#44;&#32;&#110;&#32;&#45;&#32;&#49;&#41;&#41;&#46; &#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#46;\" title=\"Rendered by QuickLaTeX.com\" height=\"72\" width=\"310\" style=\"vertical-align: -31px;\"\/><\/p>\n<p>Find the recursion depth.<!--more--><\/p>\n<p>Block-scheme of the solution:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5220\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1-1024x751.png\" alt=\"sample-recursive-functions-1\" width=\"600\" height=\"440\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1-1024x751.png 1024w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1-300x220.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1-768x563.png 768w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-1.png 1363w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><!--more--><\/p>\n<p>C++ implementation:<\/p>\n<p>[code language=&#8221;cpp&#8221;]<br \/>\n#include&lt;iostream&gt;<br \/>\nusing namespace std;<br \/>\nint depth;<\/p>\n<p>int Ackerman(int m, int n)\/\/Ackerman function<br \/>\n{<br \/>\n\tdepth++;\/\/calculate the recursion depth<br \/>\n\tif (m == 0) return n + 1;\/\/end of the recursion<br \/>\n\telse<br \/>\n\t{<br \/>\n\t\tif (n == 0) return Ackerman(m &#8211; 1, 1);\/\/recursy<br \/>\n\t\telse return Ackerman(m &#8211; 1, Ackerman(m, n &#8211; 1));<br \/>\n\t}<br \/>\n}<br \/>\nvoid main()<br \/>\n{<br \/>\n\tint m, n, result;<br \/>\n\tcout &lt;&lt; &quot;Input m &gt; 0, n &gt; 0:&quot; &lt;&lt; endl;<br \/>\n\tcin &gt;&gt; m &gt;&gt; n;\/\/input m &amp; n<\/p>\n<p>\tif (n &gt;= 0 &amp;&amp; m &gt;= 0)\/\/n &amp; m must be &gt;= 0<br \/>\n\t{<br \/>\n\t\tresult = Ackerman(m, n);\/\/calculate solution, call Accerman function<br \/>\n\t\tcout &lt;&lt; &quot;Ackerman(&quot; &lt;&lt; m &lt;&lt; &quot;,&quot; &lt;&lt; n &lt;&lt; &quot;)=&quot; &lt;&lt; result &lt;&lt; endl &lt;&lt; &quot;recursion depth = &quot; &lt;&lt; depth &lt;&lt; endl;\/\/output m, n, solution, recursion depth<br \/>\n\t}<br \/>\n\telse cout &lt;&lt; &quot;m or n &lt; 0&quot; &lt;&lt; endl;\/\/if m &amp; n &lt; 0<br \/>\n\tsystem(&quot;pause&quot;);\/\/pause console<br \/>\n}<\/p>\n<p>[\/code]<\/p>\n<p>Screenshots:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5222 aligncenter\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-2.png\" alt=\"sample-recursive-functions-2\" width=\"600\" height=\"303\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-2.png 660w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-2-300x151.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5224\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-3.png\" alt=\"sample-recursive-functions-3\" width=\"600\" height=\"306\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-3.png 656w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-3-300x153.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5226\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-4.png\" alt=\"sample-recursive-functions-4\" width=\"600\" height=\"304\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-4.png 660w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-4-300x152.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Let\u2019s use the table of values of Ackerman function from the Wikipedia to ensure that the program works properly:<\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5228\" src=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-5.png\" alt=\"sample-recursive-functions-5\" width=\"600\" height=\"387\" srcset=\"https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-5.png 789w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-5-300x194.png 300w, https:\/\/assignmentshark.com\/blog\/wp-content\/uploads\/2016\/10\/Sample-Recursive-functions-5-768x495.png 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<blockquote><p><em>This sample is not the single. You have the ability to get acquainted with more sample assignments that concern various disciplines on AssignmentShark. Our homework help service was founded to be helpful for students. Therefore, we try to post useful materials that can help students with their studying. You can look through our articles with tips and recommendations and our sample assignments any time you are in need. If it is not enough, you can also apply for assignment help to our experts. They will help you to complete your assignments quickly and correctly. Each of them is an experienced expert in the specific field. Our service is absolutely safe. There\u2019s no need to worry about your confidentiality. Try our service right now and get your <a href=\"https:\/\/assignmentshark.com\/blog\/web-assignment-sample-check-for-balanced-parentheses-in-an-expression\/\" target=\"_blank\" rel=\"noopener noreferrer\">web assignment sample<\/a> completed by one of our experts! We are available 24\/7!<\/em><\/p>\n<p><a href=\"https:\/\/assignmentshark.com\/\" target=\"_blank\" rel=\"noopener\">Help me with my assignment<\/a>. &#8211; With ease!<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Task: Find the function of the Ackerman fuction A(m, n), using the recurrence relations: Find the recursion depth.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53,35],"tags":[],"class_list":["post-5214","post","type-post","status-publish","format-standard","hentry","category-it","category-samples"],"_links":{"self":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/5214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/comments?post=5214"}],"version-history":[{"count":12,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/5214\/revisions"}],"predecessor-version":[{"id":13131,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/posts\/5214\/revisions\/13131"}],"wp:attachment":[{"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/media?parent=5214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/categories?post=5214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmentshark.com\/blog\/wp-json\/wp\/v2\/tags?post=5214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}