I need it in Java please. please help asap. TIA.
Give a linear-time algorithm for reversing a string.
import java.util.Scanner;
public class ReverseString {
/**
* Liner time algorithm for reversing a string
* @param s
* @return
*/
static String reverseString(String s) {
String result = "";
for(int i = 0; i < s.length(); ++i) { // iterate through all indices
result += s.charAt(s.length() - i - 1); // add a character from end of the string
}
return result; // return string
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a string: ");
String line = in.nextLine();
System.out.println("The reverse of \"" + line + "\" is \"" + reverseString(line) + "\".");
}
}

I need it in Java please. please help asap. TIA. Give a linear-time algorithm for reversing...
I need Help Plz in java search trees in Java Design an algorithm that converts any search tree into an AVL tree in linear time pleas with comments. You can assume that the search tree 2k-1. k ∈ N, Knot owns
Describe in pseudo-code a linear-time algorithm for reversing a queue Q. To access the queue, you are only allowed to use the methods of a queue ADT. Hint: Consider using an auxiliary data structure.
PLEASE I NEED HELP ASAP !!!!! :(:(
JAVA! Algorithm using Java Collections Framework. Please only answer if you can help... Basically we need to find an algorithm using an EFFICIENT JCF in order to get to the solution... for this problem, I need to go through a text file and output only the last 8888 lines in order that they appear...if there are fewer lines, then print all of those... But my code is too slow because I store the all lines (s.add(lines)) i think...and I can't...
I need help finding the synthesis of this problem i hope
someone can help me, TIA!
I need some help with Java. I need to write a Java program that generates a set of random strings from a given string of same length where no character is ever repeated and character belong to the original string. See example. Example Input: “Hello World” (length 9) Output: “World oHlel” (length 9)
Hi there I need help writing an algorithm to solve Sudoku puzzles through integer linear programming using MATLAB. If you could please provide the code and an explanation of how it works I'd be really grateful. Any assistance would be much appreciated, many thanks in advance!
All Codes are in java, I need the answers asap my assignment is
almost due, thanks. I'll give thumbs up.
5. (20 pts)Given the Abstract class below, Shape, draw the UML diagram for a class Square that inherits Shape. Square needs to contain a private variable called side which is a double. It should have a default no argument constructor and an overloaded constructor that takes color, filled and side. Shape -color: String -filled: boolean +Shape() +Shape(color: String, filled: boolean)...
I need help with this in JAVA. please help me. Thank
you.
In this project. you are given a unimodal array of n integer and your task is to find the maximum integer in the array in theta(logn) time. An unimodal array of integers is an array with entries that monotonically increase up to the maximum integer value and then monotonically decrease for the rest of the array. For example: (2, 5, 8, 9, 12, 15, 21, 17, 10, 4)...
i need help ASAP please
8. Consider at time t = 0, a uniform a magnetic field (directed out of the page) B-6.04" is tumed on as shown below. The loop has radius 20.0 cm and it is connected to a resistance R-5.09 shown as below. What is the magnitude of the induced emf and the current in the loop at t-2.5 sec? Is the direction of induced emf clockwise or counterclockwise in the loop? R=522