Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

Sorting_Algorithm_Visualization java logo

This project provides a comprehensive visualization of four fundamental sorting algorithms: Insertion Sort, Merge Sort, Heap Sort, and Quick Sort. The visualization is implemented using Java, making it an educational tool for understanding how these algorithms work.

  • Insertion Sort Visualization: Demonstrates the process of building a sorted array one element at a time.
  • Quick Sort Visualization: Shows the divide-and-conquer approach to sorting by partitioning arrays.
  • Heap Sort Visualization: Illustrates the process of converting an array into a heap and sorting it.
  • Merge Sort Visualization: Displays the process of dividing arrays into smaller sub-arrays and merging them back in sorted order.

Team Members

  1. Aishwarya J S
  2. Akhil Mohan
  3. Aleena Bino
  4. Aliya Nawal
  5. Amal Babu

Project Snapshots

Heap Sort

heap

Quick Sort

quick

Merge Sort

merge

Insertion Sort

insert

How it works?

1. Overall Structure:

  • The main class Sort6 and its associated helper classes (Arr, Arr_Box, GUI_Display_Arr) form the core of the application.
  • Sorting algorithms such as Insertion Sort, Merge Sort, Quick Sort, and Heap Sort are implemented and visualized through this GUI.

2.Visualization Setup:

  • Java's Swing framework is used for GUI components (JFrame, JPanel, JButton, etc.).
  • Components are organized into panels (input, update_btn, shuffle_btn, output1, output2, etc.) to manage user input, algorithm execution, and displaying results.

3.Algorithm Implementation:

  • Each sorting algorithm (insertion(), merge(), quick(), heap()) is encapsulated within methods that perform the sorting logic and update the GUI accordingly.
  • For instance, Heap Sort (heap()) initializes a max heap, performs heapification, and repeatedly extracts the maximum element to achieve sorting.

4.GUI Interaction:

  • The GUI_Display_Arr class manages the visualization of arrays and tree structures representing sorting algorithms.
  • Methods like addArr(), addTree(), warpup(), etc., handle updating the GUI with arrays, tree structures, and text descriptions of algorithm steps.

5.User Controls:

  • Buttons (start, stop, previous, next) control the flow of visualization, allowing users to start, stop, and navigate through algorithm steps.
  • Input fields (input) accept user-defined arrays for sorting, which are then visualized and processed by the sorting algorithms.

6.Execution Flow:

  • When the program starts, users input an array, choose a sorting algorithm, and initiate sorting.
  • The GUI updates dynamically to show the current state of the array and algorithm execution step-by-step.

Project Video

sorting_algorithm.1.mp4

How to configure?

  1. Install Java Development Kit (JDK)

  2. Install Visual Studio Code

  3. Set Environmental Variable for Java in the system.

    (i)Set the Variable name as 'JAVA_HOME'
    (ii)Set the Variable value to the path of your JDK installation directory.
    (iii)Under System Variables ->Path ->Edit ->New -> Add '%JAVA_HOME%\bin'

  4. Verify Installation

    In Command Prompt(cmd)

    echo %JAVA_HOME%
    

    Then

    java --version
    
  5. Install VS Code Extensions

    Search for "Java Extension Pack" and install it.

  6. Clone this repository

How to run?

 javac Sort6.java
  java Sort6

About

A DSA java project on Sorting Algorithms Visualization.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages