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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started