/algorithms-data-structures

Collection of data structures and algorithms implemented in Java, including linked lists, stacks, queues, trees, hashing, sorting, searching, and graph algorithms. Designed to provide efficient solutions for common computational problems.

Primary LanguageJava

💥 data-structures & algorithms 💥

⭐Data Structures⭐ are the programmatic way of storing data so that data can be used efficiently. ⭐Algorithm⭐ ⭐is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output.

Contributing

This repository is open for contributing. You can add new or improve already existing algorithm. I would appreciate if you check out CONTRIBUTING.md file before creating pull request. Thanks for Your time. 😊

Running algorithm

This project is customized to build with Gradle Build Tool. Gradle is an open-source build automation tool flexible enough to build almost any type of software 💚

Build with Gradle

The recommended way to execute any Gradle build is with the help of the Gradle Wrapper. The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary. All you need to do is to run commands below:

Wrapper script:

  • ./gradlew -> linux/mac OS
  • gradlew.bat Windows OS

To build whole project use

./gradlew build

build include:

:build
+--- :assemble
|    \--- :jar
|         \--- :classes
|              +--- :compileJava
|              \--- :processResources
\--- :check
     \--- :test
          +--- :classes
          |    +--- :compileJava
          |    \--- :processResources
          \--- :testClasses
               +--- :compileTestJava
               |    \--- :classes
               |         +--- :compileJava
               |         \--- :processResources
               \--- :processTestResources

Run a single algorithm:

./gradlew -PmainClass=<fully-qualified-class-name> runAlgorithm

e.g.

./gradlew -PmainClass=com.marcinseweryn.algorithms.sorting.MergeSort runAlgorithm

Run a single test

./gradlew test --tests com.marcinseweryn.algorithms.sorting.MergeSortTest 

e.g.

./gradlew test --tests <fully-qualified-class-name>  

Get the test result report in html

./gradlew testReport

Compile and run with JDK

Setup Java

  • Download and install Java

Setup folder structure

  1. Place your class files inside a directory—for example, /home/user/classdir. Note that this directory is the base directory for the package tree. If you add the class com.horstmann.corejava.Employee, then the Employee.class file must be located in the subdirectory /home/user/classdir/com/horstmann/corejava.
  2. Place any JAR files inside a directory—for example, /home/user/archives.
  3. Set the class path. The class path is the collection of all locations that can contain class files.

Compile

javac -classpath/jar MyProg.java

Run

java -classpath classes/jar MyProg

e.g.

java -classpath /home/user/classdir:.:/home/user/archives/archive.jar MyProg

or

java -classpath c:\classdir;.;c:\archives\archive.jar MyProg

Data Structures

Algorithms