Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I: Write a recursive method that displays a string in reverse order on the console using the following header: public static void reverseDisplay(String value)

Part I: Write a recursive method that displays a string in reverse order on the console using the following header:

public static void reverseDisplay(String value)

To make sure this program makes efficient use of memory, have the method call a helper method that includes the string's high index:

public static void reverseDisplay(String value, int high)

Write a program to test your recursive method by prompting the user to enter a string and then displays it in reverse order.

Sample Output:

Enter your string: Able was I, I saw Elba (user input appears in bold adjacent the prompt)

ablE was I ,I saw elbA (this is the program output)

Part II: Write a recursive method to print all permutations of a string. Then a write a program to test the method, by once again, prompting the user to enter a string of characters. For example, the permutations for the string "abc" are the following:

abc

acb

bac

bca

cab

cba

Hint: Define the following two methods. The second is a helper method.

public static void displayPermutation(String s)

public static void displayPermutation(String s1, String s2)

The first method simply invokes displayPermutation(" ", s). The second method uses a loop to move a character from s2 to s1 and recursively invokes it new s1 and s2. The base case is that s2 is empty and prints s1 to the console

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

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

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago