Skip to content

guesswhatisaac/Sorting-Algorithm-Analyzer

Repository files navigation

Sorting Algorithms Comparison

A Java-based project comparing the performance and correctness of various fundamental sorting algorithms.


🌟 PROJECT OVERVIEW

This project provides Java implementations of several common sorting algorithms, designed to read data from external files, sort it based on an integer 'idNumber', and then verify the correctness and measure the execution time of each algorithm. It serves as a comprehensive tool for understanding, comparing, and analyzing the efficiency of different sorting techniques. The core functionalities include data reading, sorting implementations, performance measurement, and correctness verification.

🎯 MOTIVATION

The primary motivation behind this project is to provide a clear, executable demonstration of fundamental sorting algorithms and facilitate their comparison. This project aims to:

  • Illustrate Sorting Concepts: Offer practical examples of how different sorting algorithms work.
  • Compare Performance: Showcase the time complexities of algorithms by measuring their execution times on various data sizes.
  • Reinforce Data Structures: Demonstrate the use of a custom 'Record' object and a 'Tree' data structure (for Tree Sort).
  • Promote Understanding: Serve as an educational resource for students and developers interested in algorithms and data structures.

🛠️ TECHNOLOGIES USED

  • Java: The primary programming language used for all implementations.

⚙️ ALGORITHMS IMPLEMENTED

The 'SortingAlgorithms.java' file contains the following sorting algorithms:

  • Insertion Sort: A simple sorting algorithm that builds the final sorted array one item at a time.
  • Selection Sort: An in-place comparison sort that divides the input list into a sorted and an unsorted region.
  • Merge Sort: A divide-and-conquer algorithm that recursively divides, sorts, and merges sub-arrays.
  • Tree Sort: A sorting algorithm that builds a binary search tree and then performs an in-order traversal to get the elements in sorted order.

🚀 GETTING STARTED

To get a local copy up and running, follow these simple steps.

Prerequisites

  • Java Development Kit (JDK): Ensure you have JDK 8 or higher installed on your system.

Project Structure

The project is organized into several '.java' files:

  • 'Main.java': The entry point of the application, responsible for reading data, initiating sorting, and printing results.
  • 'FileReader.java': Handles reading 'Record' data from specified text files.
  • 'SortingAlgorithms.java': Contains the implementations of all sorting algorithms.
  • 'Record.java': A class representing a data record with an 'idNumber' (integer) and a 'name' (String).
  • 'Node.java' & 'Tree.java': Classes that implement a binary search tree, used by the Tree Sort algorithm.

Dataset

The project is configured to read data from text files located in a 'data' directory. You will need to create this 'data' folder and place your input files within it. The path to this folder must be correctly specified in 'Main.java'.

Example data files ('random100.txt', '25000.txt', etc.) should have the following format, where N is the number of records: N ID1 Name1 ID2 Name2 ...

📊 USAGE

To run the sorting algorithm tests:

  1. Compile the Java files: Navigate to the root directory of your project in your terminal and compile the source files:

    javac *.java
    

    (Note: This simple command works if all files are in the same default package.)

  2. Ensure Data Files are Present: Make sure your 'data' directory and the input files (e.g., 'random100.txt') are correctly placed and referenced in 'Main.java'.

  3. Run the Main class:

    java Main
    

The program will execute each sorting algorithm on the configured dataset, then print the sorted records, the execution time in milliseconds, and a "CORRECT" or "FALSE" status for each algorithm. You can modify 'Main.java' to test different data files.

About

A Java-based project comparing the performance and correctness of various fundamental sorting algorithms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages