-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKlientBSTre2.java
More file actions
52 lines (33 loc) · 1.03 KB
/
Copy pathKlientBSTre2.java
File metadata and controls
52 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package KjedetBinaerSoekeTre;
import java.util.Random;
public class KlientBSTre2 {
public static void main(String[] args) {
int antallBSTre = 100;
final int ANTALL_NODER = 1024;
Random tilfeldig = new Random();
int antall = 0;
KjedetBinaerSokeTre<Integer> bs;
Integer minHoyde = ANTALL_NODER;
Integer maksHoyde = 0;
Integer gjennomsnitt = 0;
for (int i = 0; i < antallBSTre; i++) {
bs = new KjedetBinaerSokeTre<Integer>();
for (int j = 0; j < ANTALL_NODER; j++) {
Integer element = new Integer(tilfeldig.nextInt());
bs.leggTil(element);
}
antall = antall + bs.antall();
if (minHoyde > bs.hoyde()) {
minHoyde = bs.hoyde();
}
if (maksHoyde < bs.hoyde()) {
maksHoyde = bs.hoyde();
}
gjennomsnitt = gjennomsnitt + bs.hoyde();
}
System.out.println("Antall noder: " + antall);
System.out.println("Minste høyde: " + minHoyde);
System.out.println("Største høyde: " + maksHoyde);
System.out.println("Gjennomsnitt: " + gjennomsnitt / antallBSTre);
}
}