Skip to content

Commit 24bb2a1

Browse files
committed
Add some algoritns
1 parent b9abb7b commit 24bb2a1

17 files changed

+309
-0
lines changed

Diff for: .idea/.gitignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/compiler.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Computational-complexity.iml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4" />

Diff for: pom.xml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.novikov</groupId>
8+
<artifactId>complexity</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<name>complexity</name>
12+
<!-- FIXME change it to the project's website -->
13+
<url>http://www.example.com</url>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>1.8</maven.compiler.source>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
<javafx.version>13</javafx.version>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>junit</groupId>
25+
<artifactId>junit</artifactId>
26+
<version>4.11</version>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.openjfx</groupId>
31+
<artifactId>javafx-controls</artifactId>
32+
<version>${javafx.version}</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.openjfx</groupId>
36+
<artifactId>javafx-fxml</artifactId>
37+
<version>${javafx.version}</version>
38+
</dependency>
39+
</dependencies>
40+
41+
<build>
42+
<resources>
43+
<resource>
44+
<directory>src/main/java</directory>
45+
<includes>
46+
<include>**/*.fxml</include>
47+
</includes>
48+
<filtering>true</filtering>
49+
</resource>
50+
</resources>
51+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
52+
<plugins>
53+
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
54+
<plugin>
55+
<artifactId>maven-clean-plugin</artifactId>
56+
<version>3.1.0</version>
57+
</plugin>
58+
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
59+
<plugin>
60+
<artifactId>maven-resources-plugin</artifactId>
61+
<version>3.0.2</version>
62+
</plugin>
63+
<plugin>
64+
<artifactId>maven-compiler-plugin</artifactId>
65+
<version>3.8.0</version>
66+
</plugin>
67+
<plugin>
68+
<artifactId>maven-surefire-plugin</artifactId>
69+
<version>2.22.1</version>
70+
</plugin>
71+
<plugin>
72+
<artifactId>maven-jar-plugin</artifactId>
73+
<version>3.0.2</version>
74+
</plugin>
75+
<plugin>
76+
<artifactId>maven-install-plugin</artifactId>
77+
<version>2.5.2</version>
78+
</plugin>
79+
<plugin>
80+
<artifactId>maven-deploy-plugin</artifactId>
81+
<version>2.8.2</version>
82+
</plugin>
83+
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
84+
<plugin>
85+
<artifactId>maven-site-plugin</artifactId>
86+
<version>3.7.1</version>
87+
</plugin>
88+
<plugin>
89+
<artifactId>maven-project-info-reports-plugin</artifactId>
90+
<version>3.0.0</version>
91+
</plugin>
92+
</plugins>
93+
</pluginManagement>
94+
</build>
95+
</project>

Diff for: src/main/java/com/novikov/App.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.novikov;
2+
3+
/**
4+
* Hello world!
5+
*
6+
*/
7+
public class App
8+
{
9+
public static void main( String[] args )
10+
{
11+
System.out.println( "Hello World!" );
12+
}
13+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.novikov.algoritms;
2+
3+
public class BackpackTask
4+
{
5+
6+
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.novikov.algoritms;
2+
3+
public class BinarySearch
4+
{
5+
6+
//По дэфолту left = 0 , right = array.lenght
7+
public Integer binarySearchRec(Integer[]array , int key , int left , int right)
8+
{
9+
int mid = (left+right)/2;
10+
if(key == array[mid])
11+
{
12+
return mid;
13+
}
14+
if (key < array[mid])
15+
{
16+
return binarySearchRec(array,key,left,mid);
17+
}
18+
else
19+
{
20+
return binarySearchRec(array,key,mid,right);
21+
}
22+
23+
}
24+
public Integer binarySearchIterational(Integer[]array , int key)
25+
{
26+
int left = 0,right = array.length;
27+
28+
while (left <= right) // пока левая граница не "перескочит" правую
29+
{
30+
31+
int mid = (left + right) / 2; // ищем середину отрезка
32+
if (key == array[mid]) { // если ключевое поле равно искомому
33+
return mid; // мы нашли требуемый элемент,
34+
35+
}
36+
if (key < array[mid]) // если искомое ключевое поле меньше найденной середины
37+
right = mid - 1; // смещаем правую границу, продолжим поиск в левой части
38+
else // иначе
39+
left = mid + 1; // смещаем левую границу, продолжим поиск в правой части
40+
}
41+
return -(1 + left);
42+
}
43+
44+
45+
46+
47+
}

Diff for: src/main/java/com/novikov/algoritms/BubbleSort.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.novikov.algoritms;
2+
3+
public class BubbleSort
4+
{
5+
private int array[];
6+
7+
public BubbleSort(int array[])
8+
{
9+
this.array = array;
10+
}
11+
12+
public int[] sort()
13+
{
14+
for (int i = 0; i < array.length -1;i++)
15+
{
16+
for (int j = array.length - 1; j > i; j--)
17+
{
18+
if (array[j] < array[j-1])
19+
{
20+
int temp;
21+
temp = array[j];
22+
array[j] = array[j-1];
23+
array[j-1] = temp;
24+
}
25+
}
26+
}
27+
return array;
28+
}
29+
}

Diff for: src/main/java/com/novikov/algoritms/Const.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.novikov.algoritms;
2+
3+
public class Const
4+
{
5+
private int array[];
6+
7+
public Const(int[] array)
8+
{
9+
this.array = array;
10+
}
11+
public int getMidNumber()
12+
{
13+
return array[array.length/2];
14+
}
15+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.novikov.algoritms;
2+
3+
public class LinearSearch
4+
{
5+
private int array[];
6+
7+
public LinearSearch(int[] array)
8+
{
9+
this.array = array;
10+
}
11+
12+
public Integer getKey(int number)
13+
{
14+
for (int i = 0; i < array.length; i++)
15+
{
16+
if(array[i]==number) return i;
17+
}
18+
return null;
19+
}
20+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.novikov.application;
2+
3+
public class Controller
4+
{
5+
6+
}

Diff for: src/main/java/com/novikov/application/Form.fxml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.*?>
6+
<?import javafx.scene.control.*?>
7+
<?import javafx.scene.layout.*?>
8+
9+
<AnchorPane xmlns="http://javafx.com/javafx"
10+
xmlns:fx="http://javafx.com/fxml"
11+
fx:controller="com.novikov.application.Controller"
12+
prefHeight="400.0" prefWidth="600.0">
13+
14+
</AnchorPane>

Diff for: src/test/java/com/novikov/AppTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.novikov;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.Test;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
{
12+
/**
13+
* Rigorous Test :-)
14+
*/
15+
@Test
16+
public void shouldAnswerWithTrue()
17+
{
18+
assertTrue( true );
19+
}
20+
}

0 commit comments

Comments
 (0)