3
3
import com .novikov .algoritms .np .TravellingSalesmanProblem ;
4
4
import com .novikov .algoritms .p .*;
5
5
import com .novikov .validation .InputDataException ;
6
- import com .novikov .validation .Validatiton ;
7
6
8
7
import java .util .Random ;
9
8
10
9
public class AlgorithmsWorkTime
11
10
{
12
- private final int INPUT_NUMBER_MULTIPLIER = 10 ;
11
+ private int elementsCount ;
13
12
14
13
public long [][] buildGraphic (int elements , String complexity ) throws InputDataException
15
14
{
15
+ elementsCount = elements *10 ;
16
16
switch (complexity )
17
17
{
18
18
case "O(1) - Нахождение среднего элемента массива" :
@@ -35,11 +35,9 @@ public long[][] buildGraphic(int elements, String complexity) throws InputDataE
35
35
private long [][] logarithmicTime (int elements ) throws InputDataException
36
36
{
37
37
38
- int elementsCount = elements * INPUT_NUMBER_MULTIPLIER ;
39
-
40
- long [][] array = new long [elementsCount /10 ][2 ];
38
+ long [][] array = new long [elements ][2 ];
41
39
BinarySearch binarySearch = new BinarySearch ();
42
- for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
40
+ for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
43
41
{
44
42
n = n +10 ;
45
43
int [] tempArray = new BubbleSort (shuffleArray (n )).sort ();
@@ -58,10 +56,7 @@ private long[][] logarithmicTime(int elements) throws InputDataException
58
56
private long [][] quadraticTime (int elements ) throws InputDataException
59
57
{
60
58
61
-
62
- int elementsCount = elements *INPUT_NUMBER_MULTIPLIER ;
63
-
64
- long [][] array = new long [elementsCount /10 ][2 ];
59
+ long [][] array = new long [elements ][2 ];
65
60
66
61
for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
67
62
{
@@ -81,10 +76,7 @@ private long[][] quadraticTime(int elements) throws InputDataException
81
76
//2 - 1000
82
77
private long [][] constantTime (int elements ) throws InputDataException
83
78
{
84
-
85
- int elementsCount = elements * INPUT_NUMBER_MULTIPLIER ;
86
-
87
- long [][] array = new long [elementsCount /10 ][2 ];
79
+ long [][] array = new long [elements ][2 ];
88
80
for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
89
81
{
90
82
n = n + 10 ;
@@ -105,9 +97,7 @@ private long[][] constantTime(int elements) throws InputDataException
105
97
private long [][] linearTime (int elements ) throws InputDataException
106
98
{
107
99
108
- int elementsCount = elements * INPUT_NUMBER_MULTIPLIER ;
109
-
110
- long [][] array = new long [elementsCount /10 ][2 ];
100
+ long [][] array = new long [elements ][2 ];
111
101
for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
112
102
{
113
103
n = n + 10 ;
@@ -126,10 +116,7 @@ private long[][] linearTime(int elements) throws InputDataException
126
116
//2 - 30
127
117
private long [][] cubicTime (int elements ) throws InputDataException
128
118
{
129
-
130
- int elementsCount = elements * INPUT_NUMBER_MULTIPLIER ;
131
-
132
- long [][] array = new long [elementsCount /10 ][2 ];
119
+ long [][] array = new long [elements ][2 ];
133
120
for (int i = 0 , n = 0 ; n < elementsCount ; i ++)
134
121
{
135
122
n = n +10 ;
@@ -148,10 +135,7 @@ private long[][] cubicTime(int elements) throws InputDataException
148
135
// 2 - 9
149
136
private long [][] factorialTime (int elements ) throws InputDataException
150
137
{
151
-
152
- int elementsCount = elements * INPUT_NUMBER_MULTIPLIER ;
153
-
154
- long [][] array = new long [elementsCount /10 ][2 ];
138
+ long [][] array = new long [elements ][2 ];
155
139
for (int i = 0 , n = 0 ; n < elementsCount /10 ; i ++)
156
140
{
157
141
n ++;
0 commit comments