Question: There are six different methods in this task. The task is to indicate for which methods the estimated growth of the calculation time, ie the
There are six different methods in this task. The task is to indicate for which methods the estimated growth of the calculation time, ie the time complexity, is: 0 (1), for which it is 0 ((log (n)), for which it is 0 (n), for which it is 0 (nlog (n)), for which it is 0 (n ^ 2), and for which it is 0 (n ^ 3). In AlgF it is assumed that number is positive.
I denna uppgift frekommer sex olika metoder. Uppgiften r att ange fr vilka metoder den uppskattade tillvxten av berkningstiden, allts tidskompexiteten, r: 0(1), fr vilka den r O(log(n)), fr vilka den r O(n), fr vilka den r O(nlog(n)), fr vilka den r 0(na), och fr vilka den r 0(ny). I AlgF antas att tal r positivt. public static boolean algA(int[] a) { int n = a.length; Arrays. sort(a); int i = 0; int j = n-1; while (i a[j+1]) { int temp = a[j+1]; al j+1] = a[j]; a[j] = temp; } return a; public static int alg(int n) { if (n == 0) return 0; return n + algC(n/2); } } public static double algF(double tal) { double tollerans = 1/Math.pow(10, 10); double tal2 = tal/2; int n = 0; public static boolean alge(int[] a) { int n = a.length; for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
