-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPREDICTION_FOR_REPETITION
More file actions
69 lines (48 loc) · 1.77 KB
/
PREDICTION_FOR_REPETITION
File metadata and controls
69 lines (48 loc) · 1.77 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package ArrayDataPrediction;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import GenerateData.DataGenerator;
import GenerateData.Initiator;
public class CheckForRepetetion {
public static void main(String[] args) {
int arraysize;
Scanner InputSize=new Scanner(System.in);
System.out.println("Enter the size of the array: ");
arraysize= InputSize.nextInt();
DataGenerator dataGenerator = new DataGenerator(DataGenerator.PATTERN_REPEATED, arraysize);
List<Integer> GetArray=dataGenerator.generate();
System.out.println(GetArray);
Integer[] TArr=GetArray.toArray(new Integer[GetArray.size()]);
int length=TArr.length;
TestReps(TArr, length);
}
public static void TestReps(Integer TArr[],int size) {
float Threshold;
float count=0;
float Percentage;
int length=size;
Scanner ThresholdInput= new Scanner(System.in);
System.out.print("Enter the threshold percentage:");
Threshold= ThresholdInput.nextFloat()/100;
long begin = System.currentTimeMillis();
System.out.println("Threshold is set to : "+Threshold*100+"%");
System.out.println("Size of array :"+length);
Set<Integer> mySet= new HashSet<Integer>();
for(Integer ArrayElements: TArr) {
if (mySet.add(ArrayElements)==false) {
count++;
}
}
Percentage=(count/length)*100;
System.out.println("Total repetitions :"+count);
System.out.println("Percentage of repetitions: "+Percentage+"%");
if(Percentage>Threshold*100)
System.out.println("Array data type Prediction: REPEATED");
else
System.out.println("Array data type Prediction:NOT REPEATED");
long end=System.currentTimeMillis();
System.out.println("Time Taken(ms) : "+(end-begin)/1000+" seconds");
}
}