1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
noname [10]
3 years ago
15

Write the reverseO function recursively. This function takes a string and the length of the string as arguments and returns the

same string with its characters in the reverse order
Computers and Technology
2 answers:
Rudiy273 years ago
4 0

Answer:

// here is code in java.

// import package

import java.util.*;

// class definition

class Main

{

// method that return reverse string

   public static String reverseO(String st,int n)

   {

   // create an empty string

       String rev_st="";

       for(int x=n-1;x>=0;x--)

       {

       // append character from last into the empty string

           rev_st=rev_st+st.charAt(x);

       }

       // return the reversed string

       return rev_st;

   }

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

       // scanner object to read string

Scanner scr=new Scanner(System.in);

System.out.print("enter the string:");

 // read the string from user

   String st=scr.nextLine();

   // find the length of string

   int len=st.length();

   // call the method with parameter string and length

   System.out.println("reverse string is: "+reverseO(st,len));

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read a string from user and assign it to variable "st" and Find  its length. Then call the method reverseO() with parameter string and length.Then in the method reverseO(), create an empty string.Then append the characters of input string to empty string from last index.Then return the string.This will be the string in reverse order.

Output:

enter the string:hello

reverse string is: olleh

katen-ka-za [31]3 years ago
3 0

Answer:

See the other answer for the solution in Java. However, to make the reversing truly recursive, replace it by this:

 public static String reverseO(String st,int n)

  {

   String ret = st.substring(n-1,n);

   if (n > 1)  

     ret += reverseO(st, n-1);

   return ret;

 }

Explanation:

A recursive function calls itself. The function places the last character at the start and then calls itself to do the same on the remainder of the string. Make sure there always is a stop criterium, to end the recursion.

Recursive functions are often elegant, but most of the times not very efficient in terms of stack usage.

You might be interested in
Which of the following does not describe local alignment algorithm?
swat32

Answer:

The answer is "Option a".

Explanation:

A score can be detrimental. When an element has a score below zero, it means, that the sequences up to this point have no correlations, that are set to zero and its effects the previous alignment is excluded. Thus, alignment can be further found in every position later in the calculation. and other options are incorrect that can be described as follows:

  • In option b, In this option the score can be negative, that's why we can't set its value.
  • In option c, The first row and column must contain some value it can't be 0, that's why it is not correct.
  • In option d, It will start with a lower score and ends with a higher score, that's why it is not correct.

8 0
3 years ago
15 _____ 3 = 0 Question 11 options: a) / b) % c) * d) //
Vesnalui [34]
The option B is correct
5 0
3 years ago
Examine the efficiency the various recovery algorithms used in deadlock handling
sineoko [7]

Solution:

The process of transaction can guarantee the reliability of business applications. Locking resources is widely used in distributed transaction management (e.g; two phase commit, 2PC) to keep the system consistent. The locking mechanism, however, potentially results in various deadlocks. In service oriented architecture, the deadlock problem becomes even worse because multiple transactions try to lock shared resources in the unexpectable way due to the more randomicity of transaction requests, which has not been solved by existing research results. In this paper, we investigate how to prevent local deadlocks, caused by the resource competition among multiple sub-transactions of a gl obal transaction, and global deadlocks from the competition among different global transactions. We propose a replication based approach to avoid the local deadlocks, and a timestamp based approach to significantly mitigate the global deadlocks. A general algorithm is designed for both local and global deadlock prevention. The experimental results demonstrate the effectiveness and efficiency of our deadlock prevention approach. Further, it is also proved that our approach provides higher system performance than traditional resource allocation schemes.

This is the required answer.

4 0
3 years ago
The a0 is the part of the central processing unit that performs arithmetic calculations for the computer.
Serga [27]

Answer:

It is the ALU or the Arithmetic Logic Unit.

Explanation:

It is the ALU. However, keep in mind that registers and buses do a very important task. The number of registers we have, faster is the processing, and the opposite is true as well. And there is a reason behind this if we have different channels for sending and receiving the data from the memory, and several registers for storing the data, and we can formulate the requirement seeing the requirements for full adder and half adders. Remember we need to store several variables in case of the full adder, and which is the carry, and if we have separate registers for each of them, our task becomes easier. Remember its the CU that tells the ALU what operation is required to be performed. Also remember we have the same channel for input and output in the case of Van Neumann architecture, as we have a single bus. and we also have a single shared memory. And Harvard architecture is an advanced version of it.

6 0
3 years ago
Word how to create a text box with lines 2013
Crank
U go on your keypad and where the numbers are at next to the 0 u see this ------------------------- so u can make lines with that


I hope this help*static*
4 0
4 years ago
Other questions:
  • When should students practice netiquette in an online course? Check all that apply.
    14·2 answers
  • Answer the following questions:
    7·1 answer
  • When doing black and white photography, which file format should you use if possible? JPEG TIFF PNG RAW
    11·2 answers
  • What is Napoleon's friend's full name? From the Napoleon Dynamite movie.
    9·2 answers
  • Write a Unix (Linux) find-like command (myFind) in Python3 where the function will return the full paths of all the files contai
    9·1 answer
  • Which computer peripheral is used when you would like to use a DVD or CD?
    12·2 answers
  • What underlying concept is edge computing based on?
    13·2 answers
  • Is e commerce a challenge or opportunity to the freight forwarder
    8·1 answer
  • Void printInfo()
    8·1 answer
  • While operating a vehicle on any highway of this state, it it illegal to physically hold or support a wireless device with any p
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!