forked from menault/TD4_DEV51_Qualite_Algo
complexité
This commit is contained in:
@@ -2,6 +2,7 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Algorithme {
|
public class Algorithme {
|
||||||
|
// O(n²m+nm²)
|
||||||
public static void Algo(int[][] a) {
|
public static void Algo(int[][] a) {
|
||||||
if (a == null) throw new IllegalArgumentException("Tableau null");
|
if (a == null) throw new IllegalArgumentException("Tableau null");
|
||||||
int n = a.length;
|
int n = a.length;
|
||||||
@@ -26,6 +27,7 @@ public class Algorithme {
|
|||||||
for (int i = 0; i < n; i++) selection(a[i]);
|
for (int i = 0; i < n; i++) selection(a[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// O(n²)
|
||||||
public static void selection(int[] arr) {
|
public static void selection(int[] arr) {
|
||||||
int n = arr.length;
|
int n = arr.length;
|
||||||
for (int i = 0; i < n - 1; i++) {
|
for (int i = 0; i < n - 1; i++) {
|
||||||
@@ -39,12 +41,14 @@ public class Algorithme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// O(n)
|
||||||
public static int sum(int[] arr) {
|
public static int sum(int[] arr) {
|
||||||
int s = 0;
|
int s = 0;
|
||||||
for (int x : arr) s += x;
|
for (int x : arr) s += x;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// O(n²m+nm²)
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int[][] t = {
|
int[][] t = {
|
||||||
{0, 3, 2},
|
{0, 3, 2},
|
||||||
|
Reference in New Issue
Block a user