Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA All recursive methods use conditional tests to either 1. stop or 2. continue the recursion. Each recursive method has the following characteristics: 1. end/terminating

JAVA

image text in transcribed

image text in transcribed

All recursive methods use conditional tests to either 1. stop or 2. continue the recursion. Each recursive method has the following characteristics: 1. end/terminating case: One or more end cases to stop the recursion. 2. recursive case: reduces the problem in to smaller sub-problems, until it reaches (becomes) the end case. Instructions: Complete the tasks listed below. Several pieces of starter code have been provided within this lab (my-api) to help you practice recursion. You are expected to implement the bodies of the recursive methods listed below and include them in your lab report by providing a summary of their implementation. Where to find starter code in 'my-work' repository package.class : modules.RecModule package.class : week03\$recursion.RecursionTest package.class : sierpinski.fill.Viewer Task Lists 1. Complete the body for the recursive method fac(n) which computes n ! ( n factorial) for n>=0. Note: n!=n(n1)(n2)(n2) (2) (1), where n>0 and zero factorial, 0!=1. 2. Complete the body for the recursive method sum(n) to compute the sum of the first n positive integers. 3. Complete the body for the recursive method pow (x,n) for computing xn, for a positive integer n, and real number x. 4. Complete the body for the recursive method isPalindrome(str) to determine if a string of text is a palindrome. This method accepts a String and returns true if the string reads the same forwards as backwards. The string is trivially true for empty or one(1) letter strings. Hint: You should make use of the substring and charAt methods of the String. 5. Run the Viewer of the Sierpinski Triangles and give a description of what you observed as it relates to recursion. Write a short summary ( 23 sentences is enough) of your observations. Feel free to explain what the recursive solution is doing by checking out its ControlPanel

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions