Skip to content

Commit 6dc0587

Browse files
committed
remove mult 10
1 parent 133a2fa commit 6dc0587

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

src/main/java/com/novikov/algoritms/time/AlgorithmsWorkTime.java

+9-25
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import com.novikov.algoritms.np.TravellingSalesmanProblem;
44
import com.novikov.algoritms.p.*;
55
import com.novikov.validation.InputDataException;
6-
import com.novikov.validation.Validatiton;
76

87
import java.util.Random;
98

109
public class AlgorithmsWorkTime
1110
{
12-
private final int INPUT_NUMBER_MULTIPLIER = 10;
11+
private int elementsCount;
1312

1413
public long[][] buildGraphic(int elements, String complexity) throws InputDataException
1514
{
15+
elementsCount = elements*10;
1616
switch (complexity)
1717
{
1818
case "O(1) - Нахождение среднего элемента массива":
@@ -35,11 +35,9 @@ public long[][] buildGraphic(int elements, String complexity) throws InputDataE
3535
private long[][] logarithmicTime(int elements) throws InputDataException
3636
{
3737

38-
int elementsCount = elements * INPUT_NUMBER_MULTIPLIER;
39-
40-
long[][] array = new long[elementsCount/10][2];
38+
long[][] array = new long[elements][2];
4139
BinarySearch binarySearch = new BinarySearch();
42-
for (int i = 0, n = 0; n < elementsCount ; i++)
40+
for (int i = 0, n = 0; n < elementsCount; i++)
4341
{
4442
n = n+10;
4543
int[] tempArray = new BubbleSort(shuffleArray(n)).sort();
@@ -58,10 +56,7 @@ private long[][] logarithmicTime(int elements) throws InputDataException
5856
private long[][] quadraticTime(int elements) throws InputDataException
5957
{
6058

61-
62-
int elementsCount = elements *INPUT_NUMBER_MULTIPLIER;
63-
64-
long[][] array = new long[elementsCount/10][2];
59+
long[][] array = new long[elements][2];
6560

6661
for (int i = 0, n = 0; n < elementsCount ; i++)
6762
{
@@ -81,10 +76,7 @@ private long[][] quadraticTime(int elements) throws InputDataException
8176
//2 - 1000
8277
private long[][] constantTime(int elements) throws InputDataException
8378
{
84-
85-
int elementsCount = elements * INPUT_NUMBER_MULTIPLIER;
86-
87-
long[][] array = new long[elementsCount/10][2];
79+
long[][] array = new long[elements][2];
8880
for (int i = 0, n = 0; n < elementsCount ; i++)
8981
{
9082
n = n + 10;
@@ -105,9 +97,7 @@ private long[][] constantTime(int elements) throws InputDataException
10597
private long[][] linearTime(int elements) throws InputDataException
10698
{
10799

108-
int elementsCount = elements * INPUT_NUMBER_MULTIPLIER;
109-
110-
long[][] array = new long[elementsCount/10][2];
100+
long[][] array = new long[elements][2];
111101
for (int i = 0, n = 0; n < elementsCount; i++)
112102
{
113103
n = n + 10;
@@ -126,10 +116,7 @@ private long[][] linearTime(int elements) throws InputDataException
126116
//2 - 30
127117
private long[][] cubicTime(int elements) throws InputDataException
128118
{
129-
130-
int elementsCount = elements* INPUT_NUMBER_MULTIPLIER;
131-
132-
long[][] array = new long[elementsCount/10][2];
119+
long[][] array = new long[elements][2];
133120
for (int i = 0, n = 0; n < elementsCount; i++)
134121
{
135122
n = n+10;
@@ -148,10 +135,7 @@ private long[][] cubicTime(int elements) throws InputDataException
148135
// 2 - 9
149136
private long[][] factorialTime(int elements) throws InputDataException
150137
{
151-
152-
int elementsCount = elements * INPUT_NUMBER_MULTIPLIER;
153-
154-
long[][] array = new long[elementsCount/10][2];
138+
long[][] array = new long[elements][2];
155139
for (int i = 0, n = 0; n < elementsCount/10; i++)
156140
{
157141
n++;

0 commit comments

Comments
 (0)