├── .github
└── workflows
│ └── gradle-publish.yml
├── Algorithms
├── Recursion
│ └── Recursion
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── recursion
│ │ └── Recursion.java
├── Searching
│ ├── BinarySearch
│ │ └── BinarySearch
│ │ │ ├── build.xml
│ │ │ ├── manifest.mf
│ │ │ ├── nbproject
│ │ │ ├── build-impl.xml
│ │ │ ├── genfiles.properties
│ │ │ ├── project.properties
│ │ │ └── project.xml
│ │ │ └── src
│ │ │ └── binarysearch
│ │ │ └── Main.java
│ └── LinearSearch
│ │ └── LinearSearch
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── linearsearch
│ │ └── Main.java
└── Sorting
│ ├── BubbleSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── bubblesort
│ │ └── BubbleSort.java
│ ├── BucketSort
│ └── BucketSort
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── bucketsort
│ │ └── Main.java
│ ├── CountingSort
│ └── CountingSort
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── countingsort
│ │ └── CountingSort.java
│ ├── HeapSort
│ └── HeapSort
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── heapsort
│ │ ├── Heap.java
│ │ └── Main.java
│ ├── InsertionSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── insertionsort
│ │ └── InsertionSort.java
│ ├── MergeSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── mergesort
│ │ └── MergeSort.java
│ ├── QuickSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── quicksort
│ │ └── QuickSort.java
│ ├── RadixSort
│ ├── RadixSort
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ │ ├── build-impl.xml
│ │ │ ├── genfiles.properties
│ │ │ ├── project.properties
│ │ │ └── project.xml
│ │ └── src
│ │ │ └── radixsort
│ │ │ └── RadixSort.java
│ └── StringRadixSort
│ │ ├── build.xml
│ │ ├── manifest.mf
│ │ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ │ └── src
│ │ └── stringradixsort
│ │ └── StringRadixSort.java
│ ├── SelectionSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── selectionsort
│ │ └── SelectionSort.java
│ ├── ShellSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ │ ├── build-impl.xml
│ │ ├── genfiles.properties
│ │ ├── project.properties
│ │ └── project.xml
│ └── src
│ │ └── shellsort
│ │ └── ShellSort.java
│ └── StableCountingSort
│ └── StableCountingSort
│ ├── build.xml
│ ├── manifest.mf
│ ├── nbproject
│ ├── build-impl.xml
│ ├── genfiles.properties
│ ├── project.properties
│ └── project.xml
│ └── src
│ └── stablecountingsort
│ └── StableCountingSort.java
├── CaesarCipher Java
├── CaesarCipherTest
│ └── bin
│ │ ├── ConvertStringToNumbers.class
│ │ ├── Driver.class
│ │ ├── Iterator.class
│ │ ├── LetterToNumber.class
│ │ ├── NoLetterException.class
│ │ └── README.md
├── Data+Types+In+Java.pdf
├── IdeaProjects
│ └── DTPJavaMasterclass
│ │ ├── DTPJavaMasterclass.iml
│ │ ├── out
│ │ └── production
│ │ │ └── DTPJavaMasterclass
│ │ │ └── com
│ │ │ └── company
│ │ │ └── Main.class
│ │ └── src
│ │ └── com
│ │ └── company
│ │ └── Main.java
└── MessageEncipher
│ ├── ConvertStringToNumbers.java
│ ├── Cypher.java
│ ├── Driver.java
│ ├── EncipherWindow.java
│ ├── Iterator.java
│ ├── LetterToNumber.java
│ ├── MorseCodeIterator.java
│ ├── NoLetterException.java
│ ├── cypherIterator.java
│ └── morseEncryptor.java
├── Java Basic codes
├── .vscode
│ └── settings.json
├── Calco.java
├── Class.java
├── CreateDate.java
├── CreatesDate.class
├── CreatesDate.java
├── Fabronaci.class
├── Fabronaci.java
├── Factorial.class
├── Factorial.java
├── Fibronaci.class
├── Fibronaci.java
├── HashingFunction.class
├── HashingFunction.java
├── Main.class
├── Main.java
├── Power.class
├── Power.java
├── PrimalityChecker.class
├── PrimalityChecker.java
├── PrimalityCheckerr.java
├── PrimalityCheckerrr.java
├── celciusToFahrenheits
├── fahrenheitsToCelcuis.java
├── hello.java
├── randomNumberGenerator.java
├── small.c
├── small.exe
└── tempCodeRunnerFile.java
├── README.md
└── java-tutorial-for-beginners-DTP
└── README.md
/.github/workflows/gradle-publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
3 |
4 | name: Gradle Package
5 |
6 | on:
7 | release:
8 | types: [created]
9 |
10 | jobs:
11 | build:
12 |
13 | runs-on: ubuntu-latest
14 | permissions:
15 | contents: read
16 | packages: write
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: Set up JDK 11
21 | uses: actions/setup-java@v2
22 | with:
23 | java-version: '11'
24 | distribution: 'adopt'
25 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
26 | settings-path: ${{ github.workspace }} # location for the settings.xml file
27 |
28 | - name: Build with Gradle
29 | run: gradle build
30 |
31 | # The USERNAME and TOKEN need to correspond to the credentials environment variables used in
32 | # the publishing section of your build.gradle
33 | - name: Publish to GitHub Packages
34 | run: gradle publish
35 | env:
36 | USERNAME: ${{ github.actor }}
37 | TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project Recursion.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=c8e38148
2 | build.xml.script.CRC32=d62b0a35
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=c8e38148
7 | nbproject/build-impl.xml.script.CRC32=ac25645a
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/Recursion.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=recursion.Recursion
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | Recursion
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Recursion/Recursion/src/recursion/Recursion.java:
--------------------------------------------------------------------------------
1 | package recursion;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Recursion
6 | {
7 | public static void main(String[] args)
8 | {
9 | Scanner input = new Scanner(System.in);
10 | System.out.println("Enter a number: ");
11 | int userInput = input.nextInt();
12 | int result = factorialRecursive(userInput);
13 | System.out.println("Factorial: "+ userInput + "! = " + result);
14 | }
15 | public static int factorialRecursive(int num)
16 | {
17 | if(num == 1)
18 | return 1;
19 |
20 | else
21 | return num * factorialRecursive(num-1);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project BinarySearch.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=3efad8db
2 | build.xml.script.CRC32=0d1c8b5f
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=3efad8db
7 | nbproject/build-impl.xml.script.CRC32=4dfecfcf
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/BinarySearch.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=binarysearch.Main
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | BinarySearch
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Searching/BinarySearch/BinarySearch/src/binarysearch/Main.java:
--------------------------------------------------------------------------------
1 | //Done By DTP
2 | package binarysearch;
3 |
4 | public class Main {
5 | public static void main(String[] args) {
6 | int[] intArray = {-22, -15, 1, 7, 20, 35, 55};
7 | System.out.println("Iterative Binary Search");
8 | System.out.println(iterativeBinarySearch(intArray, -15));
9 | System.out.println(iterativeBinarySearch(intArray, 35));
10 | System.out.println(iterativeBinarySearch(intArray, 8888));
11 | System.out.println(iterativeBinarySearch(intArray, 1));
12 | System.out.println("Recursive Binary Search");
13 | System.out.println(iterativeBinarySearch(intArray, -15));
14 | System.out.println(iterativeBinarySearch(intArray, 35));
15 | System.out.println(iterativeBinarySearch(intArray, 8888));
16 | System.out.println(iterativeBinarySearch(intArray, 1));
17 | }
18 |
19 | public static int iterativeBinarySearch(int[] input, int value) {
20 | int start = 0;
21 | int end = input.length;
22 |
23 | while(start < end) {
24 | int midpoint = (start + end) / 2;
25 |
26 | if(input[midpoint] == value) {
27 | return midpoint;
28 | }
29 | else if(input[midpoint] > value){
30 | end = midpoint;
31 | }
32 | else {
33 | start = midpoint + 1;
34 | }
35 | }
36 | return -1;
37 | }
38 |
39 | public static int recursiveBinarySearch(int[] input, int value) {
40 | return recursiveBinarySearch(input, 0, input.length, value);
41 | }
42 |
43 | public static int recursiveBinarySearch(int[] input, int start, int end, int value)
44 | {
45 | if(start > end)
46 | return -1;
47 |
48 | int mid = (start + end) / 2;
49 |
50 | if(input[mid] == value)
51 | return mid;
52 |
53 | else if(input[mid] > value)
54 | return recursiveBinarySearch(input, start=mid+1, end, value);
55 |
56 | else
57 | return recursiveBinarySearch(input, start, end=mid, value);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project LinearSearch.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=a7b3300a
2 | build.xml.script.CRC32=502c8f97
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=a7b3300a
7 | nbproject/build-impl.xml.script.CRC32=50fd6d24
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/LinearSearch.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=linearsearch.Main
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | LinearSearch
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Searching/LinearSearch/LinearSearch/src/linearsearch/Main.java:
--------------------------------------------------------------------------------
1 | package linearsearch;
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 | int[] intArray = { 20, 35, -15, 7, 55, 1, -22};
6 |
7 | System.out.println(linearSearch(intArray, -15));
8 | System.out.println(linearSearch(intArray, 1));
9 | System.out.println(linearSearch(intArray, 8888));
10 | System.out.println(linearSearch(intArray, -22));
11 | }
12 |
13 | public static int linearSearch(int[] intArray, int num) {
14 | for(int i = 0; i < intArray.length; i++) {
15 | if(intArray[i] == num)
16 | return i;
17 | }
18 | return -1;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project BubbleSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=b6de8caf
2 | build.xml.script.CRC32=fed67c96
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=b6de8caf
7 | nbproject/build-impl.xml.script.CRC32=1df8a9b1
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/BubbleSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=bubblesort.BubbleSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | BubbleSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BubbleSort/src/bubblesort/BubbleSort.java:
--------------------------------------------------------------------------------
1 | package bubblesort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class BubbleSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | bubbleSort(unsortedArray);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | reverseBubbleSort(unsortedArray);
14 | System.out.println(Arrays.toString(unsortedArray));
15 | }
16 |
17 | public static void bubbleSort(int[] array)
18 | {
19 | for(int i = 0; i < array.length-1; i++)
20 | {
21 | for(int j = 0; j < array.length - 1 - i; j++)
22 | {
23 | if(array[j] > array[j+1])
24 | {
25 | int temp = array[j];
26 | array[j] = array[j+1];
27 | array[j+1] = temp;
28 | }
29 | }
30 | }
31 | }
32 |
33 | // This function uses the Bubble Sort algorithm to sort the numbers in the
34 | // array in decreasing order.
35 | public static void reverseBubbleSort(int[] array)
36 | {
37 | for(int i = array.length-1; i > 0; i--)
38 | {
39 | for(int j = 0; j < i; j++)
40 | {
41 | if(array[j] < array[j+1])
42 | {
43 | int temp = array[j+1];
44 | array[j+1] = array[j];
45 | array[j] = temp;
46 | }
47 | }
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project BucketSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=605e0a5b
2 | build.xml.script.CRC32=6a75b2e6
3 | build.xml.stylesheet.CRC32=8064a381@1.79.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=605e0a5b
7 | nbproject/build-impl.xml.script.CRC32=2be296f3
8 | nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/BucketSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=bucketsort.Main
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | BucketSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/BucketSort/BucketSort/src/bucketsort/Main.java:
--------------------------------------------------------------------------------
1 | package bucketsort;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | public class Main {
8 |
9 | public static void main(String[] args) {
10 | int[] intArray = { 54, 46, 83, 66, 95, 92, 43};
11 |
12 | bucketSort(intArray);
13 |
14 | for(int i = 0; i < intArray.length; i++) {
15 | System.out.println(intArray[i]);
16 | }
17 | }
18 |
19 | public static void bucketSort(int[] input) {
20 | List[] buckets = new List[10];
21 |
22 | for(int i =0; i< buckets.length; i++) {
23 | buckets[i] = new ArrayList();
24 | }
25 |
26 | for(int i = 0; i < input.length; i++){
27 | buckets[hash(input[i])].add(input[i]);
28 | }
29 |
30 | for(List bucket:buckets){
31 | Collections.sort(bucket);
32 | }
33 |
34 | int j =0;
35 | for(int i =0; i < buckets.length; i++) {
36 | for(int value: buckets[i]) {
37 | input[j++] = value;
38 | }
39 | }
40 | }
41 |
42 | private static int hash(int value) {
43 | return value /(int)10 % 10;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project CountingSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=15efb29d
2 | build.xml.script.CRC32=ab62d428
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=15efb29d
7 | nbproject/build-impl.xml.script.CRC32=afb3f71e
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/CountingSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=countingsort.CountingSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | CountingSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/CountingSort/CountingSort/src/countingsort/CountingSort.java:
--------------------------------------------------------------------------------
1 | package countingsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class CountingSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{2,5,9,8,2,8,7,10,4,3};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | countingSort(unsortedArray, 2, 10);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | }
14 |
15 | public static void countingSort(int[] array, int min, int max)
16 | {
17 | // Create counting array that keeps track of the counts
18 | int[] countArray = new int[(max-min)+1];
19 |
20 | //Traverse through the given array and begin to count the number of occurrances for each number
21 | for(int i = 0; i < array.length; i++){
22 | countArray[array[i]-min]++;
23 | }
24 |
25 | int j = 0;
26 | for(int i = min; i <= max; i++)
27 | {
28 | while(countArray[i - min] > 0)
29 | {
30 | array[j++] = i;
31 | countArray[i-min]--;
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project HeapSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=deeb3938
2 | build.xml.script.CRC32=7bb1b3b7
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=deeb3938
7 | nbproject/build-impl.xml.script.CRC32=c5a38806
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/HeapSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=heapsort.Main
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | HeapSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/src/heapsort/Heap.java:
--------------------------------------------------------------------------------
1 | package heapsort;
2 |
3 | public class Heap {
4 | private int[] heap;
5 | private int size;
6 |
7 | public Heap(int capacity){
8 | heap = new int[capacity];
9 | }
10 |
11 | public boolean isFull() {
12 | return size == heap.length;
13 | }
14 |
15 | public boolean isEmpty(){
16 | return size == 0;
17 | }
18 |
19 | public int getParent(int index){
20 | return (index-1)/2;
21 | }
22 |
23 | public int getChild(int index, boolean left) {
24 | return 2 * index + (left ? 1 : 2);
25 | }
26 |
27 | public void sort() {
28 | int lastHeapIndex = size -1;
29 |
30 | for(int i = 0; i < lastHeapIndex; i++) {
31 | int temp = heap[0];
32 | heap[0] = heap[lastHeapIndex-i];
33 | heap[lastHeapIndex - i] = temp;
34 | fixHeapBelow(0,lastHeapIndex - i - 1);
35 | }
36 | }
37 |
38 | public void insert(int value) {
39 | if(isFull())
40 | throw new IndexOutOfBoundsException("Heap is full");
41 |
42 | // Puts the item at the next available spot
43 | heap[size] = value;
44 |
45 | //Heapify: checks to see if value is greater than its parent
46 | fixHeapAbove(size);
47 |
48 | // Used to track the next available space in the array
49 | size++;
50 | }
51 |
52 | private void fixHeapAbove(int index){
53 | int newValue = heap[index];
54 | while(index > 0 && newValue > heap[getParent(index)]) {
55 | heap[index] = heap[getParent(index)];
56 | index = getParent(index);
57 | }
58 | heap[index] = newValue;
59 |
60 | }
61 |
62 | public int delete(int index){
63 | if(isEmpty())
64 | throw new IndexOutOfBoundsException("Heap is empty.");
65 |
66 | int parent = getParent(index);
67 | int deletedValue = heap[index];
68 |
69 | heap[index] = heap[size-1];
70 |
71 | if(index == 0 | heap[index] < heap[parent])
72 | fixHeapBelow(index, size-1);
73 |
74 | else
75 | fixHeapAbove(index);
76 |
77 | size--;
78 | return deletedValue;
79 | }
80 |
81 | private void fixHeapBelow(int index, int lastHeapIndex) {
82 | int childToSwap;
83 |
84 | // Gets the children of the inserted index
85 | while(index <= lastHeapIndex) {
86 | // Gets the left and right child of the parent value
87 | int leftChild = getChild(index, true);
88 | int rightChild = getChild(index, false);
89 |
90 | // Since this is a heap, there should always be a left child.
91 | // We have to check and see if there is a right child as well
92 | if(leftChild <= lastHeapIndex) {
93 |
94 | // This means that the right child does not exist so the parent can only switch
95 | // with the right child
96 | if(rightChild > lastHeapIndex) {
97 | childToSwap = leftChild;
98 | }
99 |
100 | // Compares the two children to see who is the larger value
101 | else {
102 | childToSwap = (heap[leftChild] > heap[rightChild] ? leftChild : rightChild);
103 | }
104 |
105 | // Compares the parent value with the child value
106 | // If the parent is less than the child value, swaps between the two value occurs
107 | if(heap[index] < heap[childToSwap]) {
108 | int tmp = heap[index];
109 | heap[index] = heap[childToSwap];
110 | heap[childToSwap] = tmp;
111 | }
112 | else
113 | break;
114 |
115 | index = childToSwap;
116 | }
117 | // If the parent doesnt have any children, break from the loop
118 | else
119 | break;
120 | }
121 | }
122 |
123 | public int peek() {
124 | if(isEmpty())
125 | throw new IndexOutOfBoundsException("Heap is empty");
126 |
127 | return heap[0];
128 | }
129 |
130 | public void printHeap() {
131 | for(int i = 0; i < size; i++) {
132 | System.out.print(heap[i]);
133 | System.out.print(", ");
134 | }
135 | System.out.println();
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/HeapSort/HeapSort/src/heapsort/Main.java:
--------------------------------------------------------------------------------
1 | package heapsort;
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 | Heap heap = new Heap(10);
6 |
7 | heap.insert(80);
8 | heap.insert(75);
9 | heap.insert(60);
10 | heap.insert(68);
11 | heap.insert(55);
12 | heap.insert(40);
13 | heap.insert(52);
14 | heap.insert(67);
15 | heap.printHeap();
16 | heap.sort();
17 | heap.printHeap();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project InsertionSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=c15d58eb
2 | build.xml.script.CRC32=848cf777
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=c15d58eb
7 | nbproject/build-impl.xml.script.CRC32=7298fc1e
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/InsertionSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=insertionsort.InsertionSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | InsertionSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/InsertionSort/src/insertionsort/InsertionSort.java:
--------------------------------------------------------------------------------
1 | package insertionsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class InsertionSort {
6 | public static void main(String[] args)
7 | {
8 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
9 | //System.out.println(Arrays.toString(unsortedArray));
10 | // insertionSort(unsortedArray);
11 | // System.out.println(Arrays.toString(unsortedArray));
12 | // reverseInsertionSort(unsortedArray);
13 | System.out.println(Arrays.toString(unsortedArray));
14 | recursiveInsertionSort(unsortedArray, unsortedArray.length);
15 | System.out.println(Arrays.toString(unsortedArray));
16 | }
17 |
18 | public static void insertionSort(int array[])
19 | {
20 | // Goes through the entire unsorted array starting at position 1.
21 | // Since the first element in the array is already "sorted" we use that as a
22 | // basis for where the other elements in the array should be put in the sorted
23 | // partition.
24 | for(int i = 1; i < array.length; i++)
25 | {
26 | // Stores the numerical value of the current element in a temp variable.
27 | int temp = array[i];
28 | int j;
29 |
30 | // This loop goes through the sorted left partition and compares the
31 | // curent index value to see if it is grater than it. If the element in the
32 | // sorted partition is greater than the element in the unsorted partiton,
33 | // we move the greater variable to the location of the variable we are comparing.
34 | // Essentially we are moving the greater element down to make room for the new element
35 | // being inserted into the sorted partiiton
36 |
37 | for(j = i; j > 0 && array[j-1] > temp; j--)
38 | {
39 | // Once we found an element in the sorted partititon that is greater than the
40 | // value in the unsorted partition, we push the greater element to the right
41 | array[j] = array[j-1];
42 | }
43 | // Once we are done with the loop, the position that the loop left off at
44 | // is the correct position for the unsorted element.
45 | array[j] = temp;
46 | }
47 | }
48 |
49 | // This function sorts the array in decreasing order
50 | public static void reverseInsertionSort(int[] array)
51 | {
52 | for(int i = 1; i < array.length; i++)
53 | {
54 | int temp = array[i];
55 | int j;
56 |
57 | for(j = i; j > 0; j--)
58 | {
59 | if(array[j-1] < temp)
60 | array[j] = array[j-1];
61 |
62 | else
63 | break;
64 | }
65 | array[j] = temp;
66 | }
67 | }
68 |
69 | // This function recursively sorts the array using insertion sort
70 | public static void recursiveInsertionSort(int[] array, int position)
71 | {
72 | if(position <= 1)
73 | return;
74 |
75 | // Sort first n-1 elements
76 | recursiveInsertionSort(array, position-1 );
77 |
78 | // Insert last element at its correct position
79 | // in sorted array.
80 | int last = array[position-1];
81 | int j = position-2;
82 |
83 | /* Move elements of arr[0..i-1], that are
84 | greater than key, to one position ahead
85 | of their current position */
86 | while (j >= 0 && array[j] > last)
87 | {
88 | array[j+1] = array[j];
89 | j--;
90 | }
91 | array[j+1] = last;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project MergeSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=994bf582
2 | build.xml.script.CRC32=3e7c403a
3 | build.xml.stylesheet.CRC32=8064a381@1.79.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=994bf582
7 | nbproject/build-impl.xml.script.CRC32=1ecac2e9
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/MergeSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=mergesort.MergeSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | MergeSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/MergeSort/src/mergesort/MergeSort.java:
--------------------------------------------------------------------------------
1 | package mergesort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class MergeSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | mergeSort(unsortedArray, 0, unsortedArray.length);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | descendMergeSort(unsortedArray, 0, unsortedArray.length);
14 | System.out.println(Arrays.toString(unsortedArray));
15 | }
16 |
17 | // This function divides the array into a right and left partitions until it
18 | // reaches a single element. Once it reaches two individual elements, it returns back
19 | // to the recursive function and begins to merge the right and left partitions into one
20 | // sorted partition
21 | public static void mergeSort(int array[], int start, int end)
22 | {
23 | if(end - start < 2)
24 | return;
25 |
26 | int middle = (start + end) / 2;
27 | mergeSort(array, start, middle);
28 | mergeSort(array, middle, end);
29 | merge(array, start, middle, end);
30 | }
31 |
32 | public static void merge(int array[], int start, int middle, int end )
33 | {
34 | // This if statement is looking at the last element in the left partition
35 | // and seeing if it is less than the first element in the right partition.
36 | // If it is less than the first element in the right partition, then the
37 | // order does not need to be changed.
38 | if(array[middle - 1] <= array[middle])
39 | return;
40 |
41 | int i = start;
42 | int j = middle;
43 | int tempIndex = 0;
44 | int tempArray[] = new int[end-start];
45 |
46 | // Traverses through the left and right partitons and compares the first element
47 | // of each of the partitions. Whichever is of lesser value, it gets copied to the
48 | // temp array.
49 | while(i < middle && j < end)
50 | {
51 | tempArray[tempIndex++] = array[i] <= array[j] ? array[i++] : array[j++];
52 | }
53 |
54 |
55 | System.arraycopy(array, i, array, start + tempIndex, middle - i);
56 | System.arraycopy(tempArray, 0, array, start, tempIndex);
57 | }
58 |
59 | public static void descendMergeSort(int array[], int start, int end)
60 | {
61 | if(end - start < 2)
62 | return;
63 |
64 | int middle = (start + end) / 2;
65 | descendMergeSort(array, start, middle);
66 | descendMergeSort(array, middle, end);
67 | descendMerge(array, start, middle, end);
68 | }
69 |
70 | public static void descendMerge(int array[], int start, int middle, int end )
71 | {
72 | if(array[middle - 1] >= array[middle])
73 | return;
74 |
75 | int i = start;
76 | int j = middle;
77 | int tempIndex = 0;
78 | int tempArray[] = new int[end-start];
79 |
80 | while(i < middle && j < end)
81 | {
82 | tempArray[tempIndex++] = array[i] >= array[j] ? array[i++] : array[j++];
83 | }
84 |
85 |
86 | System.arraycopy(array, i, array, start + tempIndex, middle - i);
87 | System.arraycopy(tempArray, 0, array, start, tempIndex);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project QuickSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=37dc79d3
2 | build.xml.script.CRC32=6db6a36b
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=37dc79d3
7 | nbproject/build-impl.xml.script.CRC32=99be5e18
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/QuickSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=quicksort.QuickSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | QuickSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/QuickSort/src/quicksort/QuickSort.java:
--------------------------------------------------------------------------------
1 | package quicksort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class QuickSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | quickSort(unsortedArray, 0, unsortedArray.length);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | }
14 |
15 | public static void quickSort(int[] array, int startIndex, int endIndex)
16 | {
17 | //Checks to see if the array has more than on element
18 | // If there is only one element then there is no need to sort
19 | // since it is already sorted
20 | if(endIndex-startIndex < 2)
21 | return;
22 |
23 | // This sorts the array and places the pivot index in the correct position in the array
24 | //It places all elements less than the pivot to the left of the pivot and all elements greater
25 | // than the pivot to the right of the pivot.
26 | // It then calls the quick sort algorithm to get a new pivot from the unsorted left side of the current pivot
27 | // and calls the quick sort algorithm again fo rthe right side of the current pivot.
28 |
29 | int pivotIndex = partition(array, startIndex, endIndex);
30 | quickSort(array, startIndex, pivotIndex);
31 | quickSort(array, pivotIndex+1, endIndex);
32 | }
33 |
34 | public static int partition(int[] array, int startIndex, int endIndex)
35 | {
36 | //In this version of quick sort, we will choose the first element as the pivot
37 | int pivot = array[startIndex];
38 | int i = startIndex;
39 | int j = endIndex;
40 |
41 | while(i < j)
42 | {
43 | // This loops looks decrements j until it finds an element less than
44 | // the pivot.
45 | while(i < j && array[--j] >= pivot);
46 |
47 | //Checks to make sure that the reason the while loop ended is because
48 | // it found an element less than the pivot and not because j crossed over to i.
49 | if(i < j)
50 | {
51 | array[i] = array[j];
52 | }
53 |
54 | while(i < j && array[++i] <= pivot);
55 | if(i < j)
56 | {
57 | array[j] = array[i];
58 | }
59 | }
60 |
61 | // Sets the pivot in its permanent position in the array
62 | array[j] = pivot;
63 |
64 | // Returns the position of the pivot
65 | return j;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project RadixSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=88200c98
2 | build.xml.script.CRC32=a5ab31c8
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=88200c98
7 | nbproject/build-impl.xml.script.CRC32=3b55ff04
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/RadixSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=radixsort.RadixSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | RadixSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/RadixSort/src/radixsort/RadixSort.java:
--------------------------------------------------------------------------------
1 | package radixsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class RadixSort {
6 | public static void main(String[] args) {
7 | int[] unsortedArray = {4725, 4586, 1330, 8792, 1594, 5729};
8 | System.out.println(Arrays.toString(unsortedArray));
9 | radixSort(unsortedArray, 9, 4);
10 | System.out.println(Arrays.toString(unsortedArray));
11 | }
12 |
13 | public static void radixSort(int[] input, int radix, int width)
14 | {
15 | for(int i = 0; i < width; i++)
16 | {
17 | // Calls this function for each position in the value.
18 | radixSingleSort(input, i, radix);
19 | }
20 | }
21 |
22 | public static void radixSingleSort(int[] unsortedArray, int position, int radix)
23 | {
24 |
25 | int numItems = unsortedArray.length;
26 | int[] countArray = new int[radix];
27 |
28 | // For each number in the array, this loop takes the significant digit of that number
29 | // tallies the number inside the count array so that the count array keeps track of how many
30 | // occurrances that number appears in the number array according to the digit's place
31 | for(int value: unsortedArray)
32 | {
33 | // Adds 1 to the number of occurances of this digit in the count array
34 | countArray[getDigit(position, value, radix)]++;
35 | }
36 |
37 | //This loops takes the count array containing the number of occurances and adds it
38 | // so that it displays how many occurances the number and numbers less than the number appear in the array
39 | for(int j = 1; j < radix; j++)
40 | {
41 | countArray[j] += countArray[j-1];
42 | }
43 |
44 | // Copies the values into a temp array via rigth to left of the array to preserve the order of duplicates
45 | int temp[] = new int[numItems];
46 |
47 | for(int tempIndex = numItems - 1; tempIndex >=0; tempIndex--){
48 | temp[--countArray[getDigit(position,unsortedArray[tempIndex], radix)]] =
49 | unsortedArray[tempIndex];
50 | }
51 |
52 |
53 | //Copies the values from the temp array to the unsortedArray
54 | for(int tempIndex = 0; tempIndex < numItems; tempIndex++) {
55 | unsortedArray[tempIndex] = temp[tempIndex];
56 | }
57 |
58 | }
59 |
60 | // Finds the value of the digit
61 | public static int getDigit(int position, int value, int radix)
62 | {
63 | return value/(int)Math.pow(10,position) % radix;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project StringRadixSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=11b92874
2 | build.xml.script.CRC32=3e10a8a1
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=11b92874
7 | nbproject/build-impl.xml.script.CRC32=b4cc7b84
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/StringRadixSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=stringradixsort.StringRadixSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | StringRadixSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/RadixSort/StringRadixSort/src/stringradixsort/StringRadixSort.java:
--------------------------------------------------------------------------------
1 | /*
2 | / Name: Sydnee Woodhouse
3 | / Date: 1/10/2020
4 | / Description: This program takes an array of string and sorts them
5 | / using radix sort algorithm.
6 | */
7 |
8 | package stringradixsort;
9 |
10 | import java.util.Arrays;
11 |
12 | public class StringRadixSort
13 | {
14 | public static void main(String[] args)
15 | {
16 | String[] input = {"bcdef","dbaqc","abcde","omadd","bbbbb"};
17 | System.out.println((int)'a');
18 | System.out.println(Arrays.toString(input));
19 | radixSort(5,26,input);
20 | System.out.println(Arrays.toString(input));
21 | }
22 |
23 | // This funtion compares the individual chars for each string in the array and
24 | // sends the position to the singleSortRadix to arrange th estrings accordingly in
25 | // the input array
26 | public static void radixSort(int width, int radix, String[] array)
27 | {
28 | for(int i = width-1; i >= 0; i--)
29 | {
30 | singleRadixSort(radix, i, array);
31 | }
32 | }
33 |
34 | // This function creates a counting array to keep track of how many occurrances
35 | // each of the chars appear and places the strings in order according to the
36 | // counting array
37 | public static void singleRadixSort(int radix, int position, String[] array)
38 | {
39 | int countArray[] = new int[radix];
40 |
41 | // Sets up the count array containing the number of occurances for each char in the
42 | // string
43 | for(int i = 0; i < array.length; i++)
44 | {
45 | int num = (int)(array[i].charAt(position));
46 | countArray[num-97]++;
47 | }
48 |
49 | // Adds the number of occurances and number of letters less than the current digit
50 | for(int i = 1; i < countArray.length; i++)
51 | {
52 | countArray[i]+=countArray[i-1];
53 | }
54 |
55 | // Creates a temp array to arrange the order of the array
56 | String temp[] = new String[array.length];
57 |
58 | // Finds the index of where the string should be in the final array
59 | for(int i = array.length-1; i >=0; i--)
60 | {
61 | int num = ((int)(array[i].charAt(position))) - 97;
62 | temp[--countArray[num]] = array[i];
63 | }
64 |
65 | // Copies the temp array into the final array
66 | for(int i = 0; i < array.length; i++)
67 | {
68 | array[i] = temp[i];
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project SelectionSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=0e86a28a
2 | build.xml.script.CRC32=53d7469d
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=0e86a28a
7 | nbproject/build-impl.xml.script.CRC32=da8833d1
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/SelectionSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=selectionsort.SelectionSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | SelectionSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/SelectionSort/src/selectionsort/SelectionSort.java:
--------------------------------------------------------------------------------
1 | package selectionsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class SelectionSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | selectionSort(unsortedArray);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | reverseSelectionSort(unsortedArray);
14 | System.out.println(Arrays.toString(unsortedArray));
15 | }
16 |
17 | public static void selectionSort(int array[])
18 | {
19 | for(int i = array.length-1; i > 0; i--)
20 | {
21 | int highestNum = 0;
22 |
23 | for(int j = 1; j <= i; j++)
24 | {
25 | if(array[j] > array[highestNum])
26 | highestNum = j;
27 | }
28 |
29 | int temp = array[i];
30 | array[i] = array[highestNum];
31 | array[highestNum] = temp;
32 | }
33 | }
34 |
35 | // This fucntion sorts the array in decreasing order using the Selection Sort Algorithm
36 | public static void reverseSelectionSort(int[] array)
37 | {
38 | int lowest = 0;
39 |
40 | for(int i = array.length-1; i > 0; i--)
41 | {
42 | for(int j = 1; j <= i; j++)
43 | {
44 | if(array[j] < array[lowest])
45 | lowest = j;
46 | }
47 | int temp = array[i];
48 | array[i] = array[lowest];
49 | array[lowest] = temp;
50 | lowest = 0;
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project ShellSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=8b6fb895
2 | build.xml.script.CRC32=38c60ccd
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=8b6fb895
7 | nbproject/build-impl.xml.script.CRC32=6a6bdf0e
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/ShellSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=shellsort.ShellSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | ShellSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/ShellSort/src/shellsort/ShellSort.java:
--------------------------------------------------------------------------------
1 | package shellsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class ShellSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{20,35,-15,7,55,1,-22};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | shellSort(unsortedArray);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | }
14 |
15 | public static void shellSort(int array[])
16 | {
17 | //Creates the gap to compare the elements
18 | for (int gap = array.length/2; gap > 0; gap/=2)
19 | {
20 | // Compares the value located in the gap and swaps the values if it is larger
21 | for(int i = gap; i < array.length; i++)
22 | {
23 | int temp = array[i];
24 | int j = i;
25 |
26 | while(j >= gap && array[j-gap] > temp)
27 | {
28 | array[j] = array[j-gap];
29 | j-=gap;
30 | }
31 | array[j] = temp;
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project StableCountingSort.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=d51b8505
2 | build.xml.script.CRC32=1750c1a4
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=d51b8505
7 | nbproject/build-impl.xml.script.CRC32=378f6965
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/StableCountingSort.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=stablecountingsort.StableCountingSort
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | StableCountingSort
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Algorithms/Sorting/StableCountingSort/StableCountingSort/src/stablecountingsort/StableCountingSort.java:
--------------------------------------------------------------------------------
1 | package stablecountingsort;
2 |
3 | import java.util.Arrays;
4 |
5 | public class StableCountingSort
6 | {
7 | public static void main(String[] args)
8 | {
9 | int unsortedArray[] = new int[]{2,5,9,8,2,8,7,10,4,3};
10 | System.out.println(Arrays.toString(unsortedArray));
11 | stableCountingSort(unsortedArray, 2, 10);
12 | System.out.println(Arrays.toString(unsortedArray));
13 | }
14 |
15 | static void stableCountingSort(int[] unsortedArray, int min, int max)
16 | {
17 | // Create counting array that keeps track of the counts
18 | int[] countArray = new int[(max-min)+1];
19 |
20 | // Traverse through the given array and begin to count the number of occurrances for each number
21 | for(int i = 0; i < unsortedArray.length; i++){
22 | countArray[unsortedArray[i]-min]++;
23 | }
24 |
25 |
26 | for(int i = 1; i < countArray.length; i++){
27 | countArray[i]+=countArray[i-1];
28 | }
29 |
30 |
31 | int temp[]= new int[unsortedArray.length];
32 |
33 | for(int i = temp.length-1; i >=0; i--)
34 | {
35 | temp[--countArray[unsortedArray[i]-min]] = unsortedArray[i];
36 | }
37 |
38 | // Copies the elements of the temp array to the original array
39 | for(int i = 0; i < temp.length; i++)
40 | {
41 | unsortedArray[i] = temp[i];
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/ConvertStringToNumbers.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/CaesarCipherTest/bin/ConvertStringToNumbers.class
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/Driver.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/CaesarCipherTest/bin/Driver.class
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/Iterator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/CaesarCipherTest/bin/Iterator.class
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/LetterToNumber.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/CaesarCipherTest/bin/LetterToNumber.class
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/NoLetterException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/CaesarCipherTest/bin/NoLetterException.class
--------------------------------------------------------------------------------
/CaesarCipher Java/CaesarCipherTest/bin/README.md:
--------------------------------------------------------------------------------
1 | # CaesarCipher
--------------------------------------------------------------------------------
/CaesarCipher Java/Data+Types+In+Java.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/Data+Types+In+Java.pdf
--------------------------------------------------------------------------------
/CaesarCipher Java/IdeaProjects/DTPJavaMasterclass/DTPJavaMasterclass.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CaesarCipher Java/IdeaProjects/DTPJavaMasterclass/out/production/DTPJavaMasterclass/com/company/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/CaesarCipher Java/IdeaProjects/DTPJavaMasterclass/out/production/DTPJavaMasterclass/com/company/Main.class
--------------------------------------------------------------------------------
/CaesarCipher Java/IdeaProjects/DTPJavaMasterclass/src/com/company/Main.java:
--------------------------------------------------------------------------------
1 | //Simple Interest Calculator by DTP
2 | package com.company;
3 |
4 | import java.util.Scanner;
5 |
6 | public class Main{
7 | public static void main(String[] args){
8 | double p,n,r,si;
9 | Scanner sc = new Scanner(System.in);
10 |
11 | System.out.println("Enter the Principal amount");
12 | p = sc.nextFloat();
13 |
14 | System.out.println("Enter the number of years");
15 | n = sc.nextFloat();
16 |
17 | System.out.println("Enter the rate of interest");
18 | r = sc.nextFloat();
19 |
20 | si = (p * n * r)/100;
21 |
22 | System.out.println("The interest amount is" + si);
23 | }
24 | }
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/ConvertStringToNumbers.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class ConvertStringToNumbers {
4 | static LetterToNumber singleChar = new LetterToNumber();
5 | static String[] encrypted;
6 | static String encryptedString = "";
7 | static String decriptedString = "";
8 | StringBuilder key = new StringBuilder();
9 | String s;
10 |
11 |
12 | public ConvertStringToNumbers(String s){
13 |
14 | this.s = s.toLowerCase();
15 | }
16 |
17 | public String getString(){
18 | return s;
19 | }
20 |
21 | public String convertString(){
22 |
23 | return convertStringUtil(s);
24 | }
25 |
26 | private static String convertStringUtil(String s){
27 | encrypted = new String[s.length()];
28 | for(int index = 0; index < s.length(); index++){
29 | Character c = s.charAt(index);
30 | if(Character.isLetter(c)){
31 | int letVal = singleChar.convertLetterToNumber(c);
32 | encrypted[index] = Integer.toString(singleChar.letterValue[letVal]);
33 | }
34 | else{
35 | encrypted[index] = c.toString();
36 | }
37 | }
38 | for(int x = 0; x < encrypted.length; x++)
39 | encryptedString += encrypted[x] + " ";
40 | return encryptedString;
41 | }
42 |
43 | public String convertBack() throws NoLetterException{
44 | return convertBackUtil(encrypted);
45 | }
46 |
47 | private static String convertBackUtil(String[] encripted) throws NoLetterException{
48 | for(int index = 0; index < encripted.length; index++){
49 | if(encripted[index].equals(" ") )
50 | decriptedString += " ";
51 | else{
52 | int d = Integer.parseInt(encripted[index]);
53 | decriptedString += singleChar.convertNumberToLetter(d);
54 | }
55 | //System.out.println(decriptedString);
56 | }
57 | return decriptedString;
58 | }
59 |
60 | public String key(){
61 | for(int x = 0; x < singleChar.letterValue.length; x++){
62 | if(singleChar.letterValue[x] != 0)
63 | key.append(singleChar.letters[x] + " = " + singleChar.letterValue[x] + " ");
64 | }
65 | return key.toString();
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/Cypher.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class Cypher {
3 |
4 | static char [] charTable = new char [26];
5 | static char [] charTableReg = new char [26];
6 | static Random rand = new Random();
7 |
8 | public Cypher(){
9 |
10 | int index = 0;
11 | for(int i=97; i<123; i++){
12 | charTableReg[index] = (char) i;
13 | charTable[index] = (char) i;
14 | index++;
15 | }
16 |
17 | }
18 |
19 | private static char[] randomKey(){
20 |
21 | int num1;
22 | int num2;
23 | char temp;
24 |
25 | for(int i=0; i<500; i++){
26 |
27 | num1 = rand.nextInt(26);
28 | num2 = rand.nextInt(26);
29 |
30 | temp = charTable[num1];
31 | charTable[num1] = charTable[num2];
32 | charTable[num2] = temp;
33 |
34 | }
35 |
36 |
37 | return charTable;
38 | }
39 |
40 | private static String RandomKey(){
41 |
42 | String str = "";
43 |
44 | str += "Condensed key version: ";
45 |
46 |
47 | for(int i=0; i<26; i++)
48 | str += charTable[i];
49 |
50 | return str;
51 |
52 | }
53 |
54 | public static String convertWithRandomTable(String str){
55 |
56 | char [] table = randomKey();
57 | String mixed = "";
58 | String returnStatement;
59 |
60 | for(int i=0; i 122)
124 | mixed += (char)(input%123 + 97);
125 | else
126 | mixed += (char)(input);
127 |
128 | if(adder < 10)
129 | key += "0" + Integer.toString(adder);
130 | else
131 | key += Integer.toString(adder);
132 |
133 | }
134 | else if('A' <= (str.charAt(i)) && (str.charAt(i)) <= 'Z'){
135 | input = (int)(str.charAt(i)+adder);
136 | if (input > 90)
137 | mixed += (char)(input%91 + 65);
138 | else
139 | mixed += (char)(input);
140 |
141 | if(adder < 10)
142 | key += "0" + Integer.toString(adder);
143 | else
144 | key += Integer.toString(adder);
145 | }
146 | else{
147 | mixed += str.charAt(i);
148 | key += "!!";
149 |
150 | }
151 |
152 |
153 | }
154 |
155 | completeRandKey = "key: " + key + "\n";
156 |
157 | completeRandKey += "Use every 2 characters in the key and increase the corresponding letters by the amount. " + "\n"
158 | + "Exclamation marks mean the character is a non-letter and should not be altered." + "\n";
159 |
160 | return completeRandKey + mixed;
161 | }
162 |
163 | public static String reverseCompleteRand(String key, String str){
164 |
165 | int input;
166 | String original = "";
167 | int keyIndex = 0;
168 | int adder;
169 | String twoparts;
170 |
171 | if(key.length()/2 != str.length())
172 | return "Error. Key is not vaid";
173 | else{
174 |
175 | for(int i=0; i 122)
189 | original += (char)(input%123 + 97);
190 | else
191 | original += (char)(input);
192 |
193 | }
194 | else if('A' <= (str.charAt(i)) && (str.charAt(i)) <= 'Z'){
195 | input = (int)(str.charAt(i)+adder);
196 | if (input > 90)
197 | original += (char)(input%91 + 65);
198 | else
199 | original += (char)(input);
200 | }
201 | else
202 | original += str.charAt(i);
203 |
204 | }
205 |
206 | }
207 | return original;
208 |
209 | }
210 |
211 | public static String setIncrease(int num, String str){
212 |
213 | String mixed = "";
214 | int input;
215 | String key = "";
216 |
217 | if(num < 1)
218 | return "Error. Must be a positive number.";
219 | else{
220 |
221 | for(int i=0; i 122)
227 | mixed += (char)(input%123 + 97);
228 | else
229 | mixed += (char)(input);
230 |
231 | }
232 | else if('A' <= (str.charAt(i)) && (str.charAt(i)) <= 'Z'){
233 |
234 | input = (int)(str.charAt(i)+num);
235 | if (input > 90)
236 | mixed += (char)(input%91 + 65);
237 | else
238 | mixed += (char)(input);
239 |
240 |
241 | }
242 | else
243 | mixed += str.charAt(i);
244 |
245 | }
246 | }
247 | key += ("Key: " + "decrease all letters by " + num + "\n");
248 |
249 | return key + mixed;
250 | }
251 |
252 | public static String setDecrease(int num, String str){
253 |
254 | int input;
255 | String mixed = "";
256 | String key = "";
257 |
258 | if(num < 1)
259 | return "Error. Must be a positive number.";
260 | else{
261 |
262 | for(int i=0; i buttons = new ArrayList();
19 | if (rightToLeft) {
20 | menuWindow.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
21 | }
22 |
23 | menuWindow.setLayout(new GridBagLayout());
24 | GridBagConstraints cell = new GridBagConstraints();
25 | if (windowfill) {
26 | cell.fill = GridBagConstraints.HORIZONTAL;
27 | }
28 | cell.weighty = 1;
29 |
30 | JTextField inputMessage = new JTextField("Input Message Here", 60);
31 | cell.ipady = 20;
32 | cell.weighty = 1.0;
33 | cell.anchor = GridBagConstraints.PAGE_END;
34 | cell.gridx = 1;
35 | cell.gridy = 4;
36 | cell.gridwidth = 2;
37 |
38 | menuWindow.add(inputMessage, cell);
39 |
40 | for (int i = 0; i < 8; i++) {
41 |
42 | if (i % 2 == 0) {
43 | functions = new JButton(buttonNames[i]);
44 | cell.fill = GridBagConstraints.FIRST_LINE_START;
45 | cell.weightx = 0.5;
46 | cell.gridx = 0;
47 | cell.gridy = i / 2;
48 | functions.setPreferredSize(new Dimension(300, 50));
49 | functions.addActionListener(new ActionListener() {
50 | public void actionPerformed(ActionEvent e) {
51 | checkButtonPressed(e);
52 | }
53 |
54 | private void checkButtonPressed(ActionEvent e) {
55 | // TODO Auto-generated method stub
56 | JButton btnName = (JButton) e.getSource();
57 | String name = btnName.getText();
58 | JFrame outputWindow = new JFrame("Result");
59 | outputWindow.setSize(1000, 800);
60 | outputWindow.setResizable(false);
61 | outputWindow.setLocationRelativeTo(null);
62 |
63 | Font outputFont = new Font("Sans", Font.ROMAN_BASELINE, 30);
64 |
65 | outputWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
66 | outputWindow.setVisible(true);
67 |
68 | JPanel outputPanel = new JPanel();
69 | outputWindow.add(outputPanel);
70 | outputPanel.setLayout(new BorderLayout());
71 | outputPanel.setBounds(0, 0, 600, 200);
72 | outputPanel.setBackground(Color.gray);
73 |
74 | if (name.equals(buttonNames[0])) {
75 | String messageToBeEnciphered = inputMessage.getText();
76 | cypherIterator setEncipher = new cypherIterator(messageToBeEnciphered);
77 | JLabel output = new JLabel(setEncipher.setIncrease());
78 | output.setSize(output.getPreferredSize());
79 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
80 | output.setLocation(50, 20);
81 | outputPanel.add(output);
82 | output.validate();
83 | output.setFont(outputFont);
84 | }
85 | else if (name.equals(buttonNames[2])) {
86 | String messageToBeEnciphered = inputMessage.getText();
87 | cypherIterator RandTab = new cypherIterator(messageToBeEnciphered);
88 | JLabel output = new JLabel(RandTab.convertWithRandomTable());
89 | output.setSize(output.getPreferredSize());
90 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
91 | output.setLocation(50,20);
92 | outputPanel.add(output);
93 | output.validate();
94 | output.setFont(outputFont);
95 |
96 | }
97 |
98 |
99 | else if (name.equals(buttonNames[4])) {
100 | String messageToBeEnciphered = inputMessage.getText();
101 | MorseCodeIterator morse1 = new MorseCodeIterator(messageToBeEnciphered);
102 | JLabel output = new JLabel(morse1.encrypt1(), JLabel.CENTER);
103 | output.setSize(output.getPreferredSize());
104 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
105 | output.setLocation(50,20);
106 | outputPanel.add(output);
107 | output.validate();
108 | output.setFont(outputFont);
109 |
110 |
111 | }
112 | else if (name.equals(buttonNames[6])) {
113 | String messageToBeEnciphered = inputMessage.getText();
114 | MorseCodeIterator morse3 = new MorseCodeIterator(messageToBeEnciphered);
115 | JLabel output = new JLabel(morse3.encrypt3(), JLabel.CENTER);
116 | output.setSize(output.getPreferredSize());
117 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
118 | output.setLocation(50,20);
119 | outputPanel.add(output);
120 | output.validate();
121 | output.setFont(outputFont);
122 |
123 | }
124 | }
125 | });
126 | menuWindow.add(functions, cell);
127 | buttons.add(functions);
128 | } else if (i % 2 == 1) {
129 | functions = new JButton(buttonNames[i]);
130 | cell.fill = GridBagConstraints.FIRST_LINE_START;
131 | cell.weightx = 0.5;
132 | cell.gridx = 2;
133 | cell.gridy = i/2;
134 | functions.setPreferredSize(new Dimension(300, 50));
135 | functions.addActionListener(new ActionListener() {
136 | public void actionPerformed(ActionEvent e) {
137 | checkButtonPressed(e);
138 | }
139 |
140 | private void checkButtonPressed(ActionEvent e) {
141 | JButton btnName = (JButton) e.getSource();
142 | String name = btnName.getText();
143 | JFrame outputWindow = new JFrame("Result");
144 | outputWindow.setSize(1000, 800);
145 | outputWindow.setResizable(false);
146 | outputWindow.setLocationRelativeTo(null);
147 |
148 | Font outputFont = new Font("Sans", Font.ROMAN_BASELINE, 30);
149 |
150 | outputWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
151 | outputWindow.setVisible(true);
152 |
153 | JPanel outputPanel = new JPanel();
154 | outputWindow.add(outputPanel);
155 | outputPanel.setLayout(new BorderLayout());
156 | outputPanel.setBounds(0, 0, 600, 200);
157 | outputPanel.setBackground(Color.gray);
158 | Font integerOutput = new Font("Sans", Font.ROMAN_BASELINE, 16);
159 |
160 | if(name.equals(buttonNames[1])) {
161 | String messageToBeEnciphered = inputMessage.getText();
162 | cypherIterator decreaseEncipher = new cypherIterator(messageToBeEnciphered);
163 | JLabel output = new JLabel(decreaseEncipher.setDecrease());
164 | output.setSize(output.getPreferredSize());
165 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
166 | output.setLocation(50, 20);
167 | outputPanel.add(output);
168 | output.validate();
169 | output.setFont(outputFont);
170 | }
171 | else if (name.equals(buttonNames[3])) {
172 | String messageToBeEnciphered = inputMessage.getText();
173 | cypherIterator randomEncipher = new cypherIterator(messageToBeEnciphered);
174 | JLabel output = new JLabel(randomEncipher.completeRand());
175 | output.setSize(output.getPreferredSize());
176 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
177 | output.setLocation(50, 20);
178 | outputPanel.add(output);
179 | output.validate();
180 | output.setFont(outputFont);
181 | }
182 |
183 | else if (name.equals(buttonNames[5])) {
184 | String messageToBeEnciphered = inputMessage.getText();
185 | MorseCodeIterator morse2 = new MorseCodeIterator(messageToBeEnciphered);
186 | JLabel output = new JLabel(morse2.encrypt2(), JLabel.CENTER);
187 | output.setSize(output.getPreferredSize());
188 | output.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
189 | output.setLocation(50,20);
190 | outputPanel.add(output);
191 | output.validate();
192 | output.setFont(outputFont);
193 | }
194 |
195 | else if (name.equals(buttonNames[7])) {
196 | String messageToBeEnciphered = inputMessage.getText();
197 | Iterator numEncipher = new Iterator(messageToBeEnciphered);
198 | JLabel output = new JLabel(numEncipher.encrypt());
199 | JLabel key = new JLabel(numEncipher.key());
200 | output.setSize(1000,20); key.setSize(key.getPreferredSize());
201 | output.setLocation(50,20); key.setLocation(50, 100);
202 | outputPanel.add(output); outputPanel.add(key);
203 | output.validate(); output.setFont(integerOutput); key.validate(); key.setFont(integerOutput);
204 | }
205 | }
206 | });
207 | menuWindow.add(functions, cell);
208 | buttons.add(functions);
209 | }
210 | }
211 |
212 |
213 | }
214 |
215 | private static void displayComponents() {
216 | JFrame wholeWindow = new JFrame("Message Mystifier");
217 | wholeWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
218 | wholeWindow.setSize(600, 800);
219 | wholeWindow.setResizable(false);
220 | createComponents(wholeWindow.getContentPane());
221 | wholeWindow.pack();
222 | wholeWindow.setVisible(true);
223 | }
224 |
225 | public static void main(String[] args) {
226 | javax.swing.SwingUtilities.invokeLater(new Runnable() {
227 | public void run() {
228 | displayComponents();
229 | }
230 | });
231 | }
232 | }
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/Iterator.java:
--------------------------------------------------------------------------------
1 | public class Iterator {
2 | ConvertStringToNumbers n;
3 |
4 | public Iterator(String input){
5 | n = new ConvertStringToNumbers(input);
6 | }
7 |
8 | public String encrypt(){
9 | //returns an encrypted string
10 | return n.convertString();
11 | }
12 |
13 | public String key(){
14 | //returns a key for the encryption
15 | return n.key();
16 | }
17 |
18 | public String getIterator(){
19 | //returns the inputed string
20 | return n.getString();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/LetterToNumber.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | * only works for lower case letters
5 | */
6 | public class LetterToNumber {
7 | char[] letters = "abcdefghijklmnopqrstuvwxyz".toCharArray();
8 | int[] letterValue = new int[letters.length];
9 |
10 |
11 | public int convertLetterToNumber(Character c){
12 | int beg = 0;
13 | int end = letters.length;
14 | while(end >= beg){
15 | int mid = (beg + end)/2;
16 | if(c.equals(letters[mid])){
17 | if(letterValue[mid] == 0)
18 | letterValue[mid] = (int)(Math.random() * 101) + 1;
19 | return mid;
20 | }
21 | else if(c.compareTo(letters[mid]) < 0)
22 | end = mid - 1;
23 | else if(c.compareTo(letters[mid]) > 0)
24 | beg = mid + 1;
25 | }
26 | return -1;
27 | }
28 | public char convertNumberToLetter(int letterNum) throws NoLetterException{
29 | for(int x = 0; x < letterValue.length; x++){
30 | if(letterValue[x] == letterNum)
31 | return letters[x];
32 | }
33 | throw new NoLetterException("This number does not correlate to any letter");
34 | }
35 | }
36 |
37 |
38 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/MorseCodeIterator.java:
--------------------------------------------------------------------------------
1 |
2 | public class MorseCodeIterator {
3 | morseEncryptor n = new morseEncryptor();
4 | String input;
5 |
6 | public MorseCodeIterator(String input){
7 | this.input = input;
8 | }
9 |
10 | public String encrypt1(){
11 | n.populateTable();
12 | return n.encrypt(input, 1);
13 | }
14 |
15 | public String encrypt2(){
16 | n.populateTable();
17 | return n.encrypt(input, 2);
18 | }
19 |
20 | public String encrypt3(){
21 | n.populateTable();
22 | return n.encrypt(input, 3);
23 | }
24 |
25 | //key generated?
26 | }
27 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/NoLetterException.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class NoLetterException extends Exception {
4 | public NoLetterException(String arg){
5 | super(arg);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/cypherIterator.java:
--------------------------------------------------------------------------------
1 |
2 | import java.util.*;
3 | public class cypherIterator {
4 |
5 | Random rand = new Random();
6 | int num = rand.nextInt(25) + 1;
7 | Cypher n = new Cypher();
8 | String input;
9 |
10 | public cypherIterator(String in){
11 | input = in;
12 | }
13 |
14 | public String convertWithRandomTable(){
15 |
16 | return Cypher.convertWithRandomTable(input);
17 | }
18 |
19 | public String setIncrease(){
20 |
21 | return Cypher.setIncrease(num, input);
22 | }
23 |
24 | public String setDecrease(){
25 |
26 | return Cypher.setDecrease(num, input);
27 | }
28 |
29 | public String completeRand(){
30 |
31 | return Cypher.completeRand(input);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/CaesarCipher Java/MessageEncipher/morseEncryptor.java:
--------------------------------------------------------------------------------
1 | /*How to:
2 | morseEncryptor.populateTable(); has to be done before encryption.
3 |
4 | String input = "input here";
5 | Options 1-3.
6 |
7 | String output = encrypt(input, option);
8 | to encrypt
9 |
10 | String output = decrypt(input);
11 | to decrypt
12 | */
13 |
14 |
15 | public class morseEncryptor{
16 |
17 | public static String [] morseTable = new String [36];
18 |
19 | public void populateTable(){
20 | morseTable[0] = ".-";
21 | morseTable[1] = "-...";
22 | morseTable[2] = "-.-.";
23 | morseTable[3] = "-..";
24 | morseTable[4] = ".";
25 | morseTable[5] = "..-.";
26 | morseTable[6] = "--.";
27 | morseTable[7] = "....";
28 | morseTable[8] = "..";
29 | morseTable[9] = ".---";
30 | morseTable[10] = "-.-";
31 | morseTable[11] = ".-..";
32 | morseTable[12] = "--";
33 | morseTable[13] = "-.";
34 | morseTable[14] = "---";
35 | morseTable[15] = ".--.";
36 | morseTable[16] = "--.-";
37 | morseTable[17] = ".-.";
38 | morseTable[18] = "...";
39 | morseTable[19] = "-";
40 | morseTable[20] = "..-";
41 | morseTable[21] = "...-";
42 | morseTable[22] = ".--";
43 | morseTable[23] = "-..-";
44 | morseTable[24] = "-.--";
45 | morseTable[25] = "--..";
46 | }
47 |
48 | public static String toMorse(String input){
49 | input = input.toLowerCase();
50 | input = morseTable[input.charAt(0)-97];
51 | return input;
52 | }
53 |
54 | public static String stringToMorse(String input){
55 | input = input.toLowerCase();
56 | String output = "";
57 |
58 | for (int x = 0; x < input.length(); x++){
59 | if(input.substring(x, x+1).equals(" ")){
60 | output += " ";
61 | }
62 | else{
63 | output += toMorse(input.substring(x, x+1)) + " ";
64 | }
65 | }
66 | return output;
67 | }
68 |
69 | public static String morseToString(String input){
70 | for(int x = 0; x < 26; x++){
71 | if(input.equals(morseTable[x])){
72 | return Character.toString((char) (x+97));
73 | }
74 | }
75 | return "";
76 | }
77 |
78 | public static String deMorse(String input){
79 | String output = "";
80 | int start = 0;
81 | for (int x = 0; x < input.length(); x++){
82 | if(input.substring(x,x+1).equals(" ")){
83 | output += morseToString(input.substring(start,x)) + " ";
84 | start = x+1;
85 | }
86 | output += morseToString(input.substring(start));
87 | }
88 |
89 | return output;
90 | }
91 |
92 | public static String invert(String input){
93 | String output = "";
94 | for(int x = 0; x < input.length(); x++){
95 | if(input.substring(x, x+1).equals("-")){
96 | output += ".";
97 | }
98 | else if(input.substring(x, x+1).equals(".")){
99 | output += "-";
100 | }
101 | else{
102 | output += " ";
103 | }
104 | }
105 | return output;
106 | }
107 |
108 | public static String encrypt1(String input){
109 | String output = invert(input);
110 | output += "--.--";
111 | return output;
112 | }
113 |
114 | public static String decrypt1(String input){
115 | String output = input.substring(0, input.length()-5);
116 | output = invert(output);
117 | output = deMorse(output);
118 | return output;
119 | }
120 |
121 | public static String reverse(String input){
122 | String output = "";
123 | for(int x = 0; x < input.length(); x++){
124 | output += input.substring(input.length()-1-x, input.length()-x);
125 | }
126 | return output;
127 | }
128 |
129 | public static String encrypt2(String input){
130 | String output = reverse(input);
131 | output += ".-..-";
132 | return output;
133 | }
134 |
135 | public static String decrypt2(String input){
136 | String output = input.substring(0, input.length()-5);
137 | output = reverse(output);
138 | output = deMorse(output);
139 | return output;
140 | }
141 |
142 | public static String swap(String input){
143 | String output = "";
144 | for(int x = 0; x < input.length(); x++){
145 | if(x%2==1){
146 | output += input.substring(x,x+1);
147 | output += input.substring(x-1, x);
148 | }
149 | }
150 | if(input.length()%2==1){
151 | output += input.substring(input.length()-1,input.length());
152 | }
153 | return output;
154 | }
155 |
156 | public static String encrypt3(String input){
157 | String output = swap(input);
158 | output += "--..-";
159 | return output;
160 | }
161 |
162 | public static String decrypt3(String input){
163 | String output = input.substring(0, input.length()-5);
164 | output = swap(output);
165 | output = deMorse(output);
166 | return output;
167 | }
168 |
169 | public String encrypt(String input, int option){
170 | input = stringToMorse(input);
171 | if(option == 1){
172 | return encrypt1(input);
173 | }
174 | if(option == 2){
175 | return encrypt2(input);
176 | }
177 | if(option == 3){
178 | return encrypt3(input);
179 | }
180 | else{
181 | return input;
182 | }
183 | }
184 |
185 | public static String decrypt(String input){
186 | String key = input.substring(input.length()-5, input.length());
187 | if(key.equals("--.--")){
188 | return decrypt1(input);
189 | }
190 | else if (key.equals(".-..-")){
191 | return decrypt2(input);
192 | }
193 | else if (key.equals("--..-")){
194 | return decrypt3(input);
195 | }
196 | else{
197 | return input;
198 | }
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/Java Basic codes/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "java.project.sourcePaths": [
3 | ""
4 | ]
5 | }
--------------------------------------------------------------------------------
/Java Basic codes/Calco.java:
--------------------------------------------------------------------------------
1 | import jdk.jfr.internal.Utils;
2 |
3 | public class Calco {
4 | public static void calculate() {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/Java Basic codes/Class.java:
--------------------------------------------------------------------------------
1 | Class
--------------------------------------------------------------------------------
/Java Basic codes/CreateDate.java:
--------------------------------------------------------------------------------
1 | //Simple Program to Display The Current Date and Time
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT...😉
4 | import java.util.Date;
5 |
6 | public class CreateDate {
7 | public static void main(String args[]) {
8 | Date d1, d2, d3;
9 |
10 | d1 = new Date();
11 | System.out.println("Date and Time: " + d1);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Java Basic codes/CreatesDate.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/CreatesDate.class
--------------------------------------------------------------------------------
/Java Basic codes/CreatesDate.java:
--------------------------------------------------------------------------------
1 | import java.util.Date;
2 |
3 | public class CreatesDate {
4 |
5 |
6 | public static void main(String args[]) {
7 | int a,b ,c;
8 | Date d1;
9 | d1 = new Date();
10 | System.out.println("Date 1: " + d1);
11 |
12 |
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/Java Basic codes/Fabronaci.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/Fabronaci.class
--------------------------------------------------------------------------------
/Java Basic codes/Fabronaci.java:
--------------------------------------------------------------------------------
1 | //Predefint Fabronaci for Number(num) == 5
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT...😉
4 | public class Fibronaci {
5 |
6 | public static int num = 5, fad = 1, i;
7 |
8 | public static void main(String[] args) {
9 | for (i = 0; i <= num; i++) {
10 | fad += i - 1;
11 |
12 | }
13 | System.out.println("Fabronaci of " + num + ": " + fad);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Java Basic codes/Factorial.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/Factorial.class
--------------------------------------------------------------------------------
/Java Basic codes/Factorial.java:
--------------------------------------------------------------------------------
1 | //Predefint factorial and Fabronci for Number(num or n) == 5
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT😉
4 | public class Factorial {
5 | public static int num = 5, i, fact = 1, n = 5, fad = 1, j;;
6 |
7 | public static void main(String[] args) {
8 | for (i = 1; i <= num; i++) {
9 | fact = fact * i;
10 |
11 | }
12 | System.out.println("Fact: " + fact);
13 | for (j = 0; j <= n; j++) {
14 | fad += j - 1;
15 |
16 | }
17 | System.out.println("Fabronaci of " + n + ": " + fad);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Java Basic codes/Fibronaci.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/Fibronaci.class
--------------------------------------------------------------------------------
/Java Basic codes/Fibronaci.java:
--------------------------------------------------------------------------------
1 | //Predefint Fabronaci for Number(num) == 5
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT...😉
4 | public class Fibronaci {
5 |
6 | public static int num = 5, fid = 1, i;
7 |
8 | public static void main(String[] args) {
9 | for (i = 0; i <= num; i++) {
10 | fid += i - 1;
11 |
12 | }
13 | System.out.println("Fabronaci of " + num + ": " + fid);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Java Basic codes/HashingFunction.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/HashingFunction.class
--------------------------------------------------------------------------------
/Java Basic codes/HashingFunction.java:
--------------------------------------------------------------------------------
1 | package com.company;
2 |
3 | import java.math.BigInteger;
4 | import java.security.MessageDigest;
5 | import java.security.NoSuchAlgorithmException;
6 |
7 | public class HashingFunction {
8 | public static String encryptThisString(String input) {
9 | try {
10 | // getInstance() method is called with algorithm SHA-1
11 | MessageDigest md = MessageDigest.getInstance("SHA-1");
12 |
13 | // digest() method is called
14 | // to calculate message digest of the input string
15 | // returned as array of byte
16 | byte[] messageDigest = md.digest(input.getBytes());
17 |
18 | // Convert byte array into signum representation
19 | BigInteger no = new BigInteger(1, messageDigest);
20 |
21 | // Convert message digest into hex value
22 | String hashtext = no.toString(16);
23 |
24 | // Add preceding 0s to make it 32 bit
25 | while (hashtext.length() < 32) {
26 | hashtext = "0" + hashtext;
27 | }
28 |
29 | // return the HashText
30 | return hashtext;
31 | }
32 |
33 | // For specifying wrong message digest algorithms
34 | catch (NoSuchAlgorithmException e) {
35 | throw new RuntimeException(e);
36 | }
37 | }
38 |
39 | // Driver code
40 | public static void main(String args[]) throws NoSuchAlgorithmException {
41 |
42 | System.out.println("HashCode Generated by SHA-1 for: ");
43 |
44 | String s1 = "ROOT";
45 | System.out.println("\n" + s1 + " : " + encryptThisString(s1));
46 |
47 | String s2 = "TERENCE";
48 |
49 | System.out.println("\n" + s2 + " : " + encryptThisString(s2));
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Java Basic codes/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/Main.class
--------------------------------------------------------------------------------
/Java Basic codes/Main.java:
--------------------------------------------------------------------------------
1 | //Done by Daniel THeProgrammer
2 | //A Program to Find Odd and even numbers from arrays using Loops
3 | //Here,It will print out the Even Numbers Completely then followed by the Odd NUmbers
4 | package com.company;
5 |
6 | public class Main{
7 | public static void main(String[] args){
8 | int numbers[]={1,2,3,4,5,6,7,8,9};
9 | int even[] = new int[5];
10 | int odd[] = new int [6];
11 | int i=0;
12 | int j=0;
13 |
14 | for(int a:numbers){
15 | if (a%2 ==0){
16 | even[i]=a;
17 | i++;
18 | }else{
19 | odd[j]=a;
20 | j++;
21 | }
22 | }
23 | for(int x:even){
24 | System.out.println(x);
25 | }
26 | for(int y:odd){
27 | System.out.println(y);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Java Basic codes/Power.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/Power.class
--------------------------------------------------------------------------------
/Java Basic codes/Power.java:
--------------------------------------------------------------------------------
1 |
2 | //Program to return a number(base) raise to it's exponent
3 | //DECLERE VARIABLE NOT WARS!! copyright©2021
4 | //By ROOT...😉
5 | //-----------------------------------------------------
6 | import java.util.Scanner;
7 |
8 | public class Power {
9 | private static Scanner scan;
10 |
11 | public static void main(String[] args) {
12 | double power = 1;
13 | int num, i, exp;
14 |
15 | scan = new Scanner(System.in);
16 |
17 | System.out.print("Enter a number:");
18 | num = scan.nextInt();
19 |
20 | System.out.print("Enter the exponent:");
21 | exp = scan.nextInt();
22 | for (i = 1; i <= exp; i++) {
23 | power = power * num;
24 |
25 | }
26 | System.out.println("\nAnswer: " + power);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Java Basic codes/PrimalityChecker.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/PrimalityChecker.class
--------------------------------------------------------------------------------
/Java Basic codes/PrimalityChecker.java:
--------------------------------------------------------------------------------
1 |
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT...😉
4 | //-----------------------------------------------------
5 | import java.util.Scanner;
6 |
7 | //import jdk.javadoc.internal.doclets.formats.html.SourceToHTMLConverter;
8 |
9 | public class PrimalityChecker {
10 | private static Scanner scan;
11 |
12 | public static int isPrime(int n) {
13 |
14 | if (n <= 1) {
15 | System.out.println("Any Number Less Than Or Equal To 1 Is Non Prime");
16 | }
17 |
18 | else if (n >= 2) {
19 | for (int i = 2; i < n; i++) {
20 | if (n % i == 0)
21 | System.out.println("Number Is Non Prime");
22 | }
23 | } else {
24 | System.out.println("Number Is Non Prime");
25 | }
26 | }
27 |
28 | public static void main(String[] args) {
29 | scan = new Scanner(System.in);
30 |
31 | System.out.print("Enter a number:");
32 | num = scan.nextInt();
33 |
34 | if (isPrime(num))
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Java Basic codes/PrimalityCheckerr.java:
--------------------------------------------------------------------------------
1 | package JAVA;
2 | import java.util.Scanner;
3 |
4 | //import jdk.javadoc.internal.doclets.formats.html.SourceToHTMLConverter;
5 |
6 | public class PrimalityCheckerr {
7 | private static Scanner scan;
8 |
9 | }
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Java Basic codes/PrimalityCheckerrr.java:
--------------------------------------------------------------------------------
1 |
2 | package JAVA;
3 |
4 | //DECLERE VARIABLE NOT WARS!! copyright©2021
5 | //By ROOT...😉
6 | //-----------------------------------------------------
7 | import java.util.Scanner;
8 |
9 | import java.util.Scanner;
10 | //import jdk.javadoc.internal.doclets.formats.html.SourceToHTMLConverter;
11 |
12 | public class PrimalityCheckerrr {
13 | private static Scanner scan;
14 |
15 | public static int isPrime(int n) {
16 |
17 | if (n <= 1) {
18 | System.out.println("Number Is Non Prime");
19 | }
20 |
21 | else if (n >= 2) {
22 | for (int i = 2; i < n; i++) {
23 | if (n % i == 0)
24 | System.out.println("Number Is Non Prime");
25 | }
26 | } else {
27 | System.out.println("Number Is Non Prime");
28 | }
29 | }
30 |
31 | public static void main(String[] args) {
32 | scan = new Scanner(System.in);
33 |
34 | System.out.print("Enter a number:");
35 | num = scan.nextInt();
36 |
37 | if (isPrime(num))
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Java Basic codes/celciusToFahrenheits:
--------------------------------------------------------------------------------
1 | //Done by Neba Emmanuel
2 | //Look me up on https://github.com/Neba-Emmanuel/
3 | import java.util.Scanner;
4 |
5 | public class celciusToFahrenheit {
6 | public static void main() {
7 | float c,f;
8 |
9 | Scanner i = new Scanner(System.in);
10 |
11 | System.out.println("Enter temperature in centigrade: ");
12 | c = i.nextFloat();
13 | f = (float)((1.8 * c) + 32.0);
14 |
15 | System.out.println("Temperature in Fahrenheit = "+f);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Java Basic codes/fahrenheitsToCelcuis.java:
--------------------------------------------------------------------------------
1 | //Done by Neba Emmanuel
2 | //Look me up on https://github.com/Neba-Emmanuel/
3 | import java.util.Scanner;
4 |
5 | public class fahrenhritToCelcius {
6 | public static void main() {
7 | float c,f;
8 |
9 | Scanner i = new Scanner(System.in);
10 |
11 | System.out.println("Enter temperature in Fahrenheit: ");
12 | f = i.nextFloat();
13 | c = (float)((f - 32) / 1.8);
14 |
15 | System.out.println("Temperature in Centigrate = "+c);
16 | }
17 | }
--------------------------------------------------------------------------------
/Java Basic codes/hello.java:
--------------------------------------------------------------------------------
1 | /**
2 | * hello.....
3 | */
4 | public class hello {
5 |
6 | public static void main(String[] args) {
7 | System.out.println("Hello TERENCE😛");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Java Basic codes/randomNumberGenerator.java:
--------------------------------------------------------------------------------
1 | //Done by Neba Emmanuel
2 | //Look me up on https://github.com/Neba-Emmanuel/
3 | import java.util.Scanner;
4 | import java.util.Random;
5 |
6 | public class randomNumberGenerator {
7 | public static void main() {
8 | int n, max, c;
9 |
10 | Scanner i = new Scanner(System.in);
11 |
12 | System.out.println("Enter the number of random numbers you want: ");
13 | n = i.nextInt();
14 | System.out.println("Enter the max of the random number: ");
15 | max = i.nextInt();
16 |
17 | Random t = new Random();
18 | System.out.println("Random Numbers:");
19 | for(c = 1; c <= n; c++){
20 | System.out.println(t.nextInt(max));
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Java Basic codes/small.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | int a, b, sum;
6 | printf("Enter a numer: ");
7 | scanf("%d", &a);
8 | printf("Enter a Second number: ");
9 | scanf("%d", &b);
10 |
11 | sum = a + b;
12 |
13 | printf("Sum = %d ", sum);
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/Java Basic codes/small.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Daniel-TheProgrammer/JAVA/c925bf8280b8304841fa1c9b0470107382222b77/Java Basic codes/small.exe
--------------------------------------------------------------------------------
/Java Basic codes/tempCodeRunnerFile.java:
--------------------------------------------------------------------------------
1 |
2 | //DECLERE VARIABLE NOT WARS!! copyright©2021
3 | //By ROOT...😉
4 | //-----------------------------------------------------
5 | import java.util.Scanner;
6 |
7 | //import jdk.javadoc.internal.doclets.formats.html.SourceToHTMLConverter;
8 |
9 | public class PrimalityChecker {
10 | private static Scanner scan;
11 |
12 | public static int isPrime(int n) {
13 |
14 | if (n <= 1) {
15 | System.out.println("Number Is Non Prime");
16 | }
17 |
18 | else if (n >= 2) {
19 | for (int i = 2; i < n; i++) {
20 | if (n % i == 0)
21 | System.out.println("Number Is Non Prime");
22 | }
23 | } else {
24 | System.out.println("Number Is Non Prime");
25 | }
26 | }
27 |
28 | }
29 | int num;
30 | public static void main(String[] args) {
31 | scan = new Scanner(System.in);
32 |
33 | System.out.print("Enter a number:");
34 | num = scan.nextInt();
35 |
36 | isPrime(num)
37 |
38 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JAVA-REPO
2 | Get Started With Java
3 |
--------------------------------------------------------------------------------