Salut J'ai une question que c'est ma classe qui pour chaque "n" obtiendra le temps moyen pour cela. aussi la méthode que je veux prendre sa performance a T (n) = O (nlogn)Performance dans le temps
mon code:
public class NewClass1 {
public static void main(String[] args) {
List<Point> randList = new ArrayList<Point>();
for (int n = 100; n <= 500; n+=200) {
Random rand = new Random();
for (int i = 1; i <= n; i++) {
Point point = new Point(rand.nextInt(10), rand.nextInt(10));
randList.add(point);
}
get(randList);
}
}
public static void get(List<Point> list) {
long time = 0;
for(int i=1;i<10;i++) {
long t = System.currentTimeMillis();
GrahamVersion.grahamScan(list);
long t0 = System.currentTimeMillis();
time = time+t0-t;
}
System.out.println((double)time/10);
}
}
et imprimera:
1.5
1.6
0.0
le temps moyen est OK? parce que pour n = 500
aura 0.0
et n = 300
aura 1.6
Dans cette méthode, j'ai utilisé une méthode de tri qui a T (n) = O (nlogn) – user472221