Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overvievw This lab is designed regular recursion and tail recursion, the use of base cases, the concept of the to illustrate concepts and characteristics of

image text in transcribed

image text in transcribed

Overvievw This lab is designed regular recursion" and "tail recursion," the use of base cases, the concept of the to illustrate concepts and characteristics of recursion, including the difference between call stack, and arithmetic in statements. You will write three different methods and a tmain method. Note that if one of your recursive methods is over ten lines of code, you are very likely overcomplicating it. This lab will not check for error handling. You must strictly follow the given method signatures. Details and Requirements 1. Write a method with the following signature: public static void recursivePrinter (int levels) or however many levels are specified, the method must print "Going down!" that many times in a row, and then print "Coming back up!" the same nomber of times, with levels appended. Example recur sivePrinter (3); Output: Going down! 3 Going down 2 Going down! 1 Coming back up! 1 Coming back up! 2 Coming back up! 3 Explanation: when operations occur after a recursive call, that is an example of regular recursion. When the recursive call occurs after all operations have finished, that is an example of tail recursion. 2. Write a method with the following signature; public static void reversePrint (String str) This method must take a string and print it in reverse, printing one character at a time. Hint: try using substrings. It is possible to prin the string in reverse whule traversing it from left to righr. Example: reversePrint ("Alphabet"); Output tebahplA 3. Write a method with the following signature: public static int factorial(int num) This method must return the factorial of the given number. A factorial is an integer multiplied by all non negative integer less than itTE51:3.4.3 1 120 Note l! and Ol both equal. Example factorial(8); Return value: 48320

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

Students also viewed these Databases questions