In: Computer Science
Give pseudocode for a recursive function that sorts all letters
in a string. For example, the string "goodbye" would be sorted into
"bdegooy".
Python
PSEUDO CODE TO REVERSE A STRING
//custom Method to reverse the String
   public static String newreversedString(String
input)
   {   
   if ((input.length() <= 1)||(input==null) )
   return input;
  
   //Returning the reversed String
   return newreversedString(input.substring(1)) +
input.charAt(0);
   }
COMPLETE JAVA CODE
package reverseString;
import java.util.Scanner;
public class Recursion {
   public static void main(String[] args)
   {
   System.out.print("Enter a string to reverse it by
recursion: ");
   String input;
   Scanner scan = new Scanner(System.in);
  
   //Inputting the String to reverse
   input=scan.nextLine();
  
   //Calling the newreversedString() method and storing
in
   //output variable
   String output= newreversedString(input);
  
   //Printing reversed String
   System.out.println("Reverse of input String
\""+input+"\" is \""+output+"\"");
   }
     
   //Method to reverse the String
   public static String newreversedString(String
input)
   {   
   if ((input.length() <= 1)||(input==null) )
   return input;
  
   //Returning the reversed String
   return newreversedString(input.substring(1)) +
input.charAt(0);
   }
}
OUTPUT
