What is the order of growth of the running time of the following two functions? Each function takes a string as an argument and returns the string reversed.
public static String reverse1(String s){ int n = s.length(); String reverse = ""; for (int i = 0; i < n; i++) reverse = s.charAt(i) + reverse; return reverse;}public static String reverse2(String s){ int n = s.length(); if (n <= 1) return s; String left = s.substring(0, n/2); String right = s.substring(n/2, n) ; return reverse2(right) + reverse2(left);}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.