Question: from my java ,algorithm classes 5.44 - Create a main to test the runtimes of the 2 methods listed in the book. Above each of
from my java ,algorithm classes
5.44 - Create a main to test the runtimes of the 2 methods listed in the book. Above each of the books methods that you added to your code, put in a comment stating the runtime. Maybe include a nice graph? You can start with the Chapter5Problem44Strings.java file below
public class Chapter5Problem44Strings { public static void main(String[] args) { } //TODO List the BigOh Runtime Here: public static String makeLongString1( int N ) { String result = ""; for( int i = 0; i < N; i++ ) result += "x"; return result; } //TODO List the BigOh Runtime Here: public static String makeLongString2( int N ) { StringBuilder result = new StringBuilder( "" ); for( int i = 0; i < N; i++ ) result.append( "x" ); return new String( result ); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
