https://github.com/mehmetkahya0/bubble-sorting
This project visualizes the Bubble Sort algorithm using a graphical interface built with Tkinter and Matplotlib. It allows users to input a list of numbers, sort them using Bubble Sort, and see both the original and sorted arrays in a visual format
https://github.com/mehmetkahya0/bubble-sorting
algiorithimcs algorithm-competitions algorithms bubble bubble-sort bubble-sort-algorithm bubblesort gui python python3 tkinter tkinter-gui
Last synced: 8 months ago
JSON representation
This project visualizes the Bubble Sort algorithm using a graphical interface built with Tkinter and Matplotlib. It allows users to input a list of numbers, sort them using Bubble Sort, and see both the original and sorted arrays in a visual format
- Host: GitHub
- URL: https://github.com/mehmetkahya0/bubble-sorting
- Owner: mehmetkahya0
- Created: 2024-05-21T18:11:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-03T11:50:59.000Z (about 1 year ago)
- Last Synced: 2024-08-03T12:51:12.707Z (about 1 year ago)
- Topics: algiorithimcs, algorithm-competitions, algorithms, bubble, bubble-sort, bubble-sort-algorithm, bubblesort, gui, python, python3, tkinter, tkinter-gui
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bubble Sort Visualization
This project visualizes the Bubble Sort algorithm using a graphical interface built with Tkinter and Matplotlib. It allows users to input a list of numbers, sort them using Bubble Sort, and see both the original and sorted arrays in a visual format.
## Features
- User-friendly graphical interface
- Input field for entering numbers
- Displays the original and sorted arrays
- Shows the number of swaps made during sorting
- Uses bar charts to visualize the arrays## Installation
To run this project, you need to have Python installed on your machine. Additionally, you need to install the following libraries:
- Tkinter
- MatplotlibYou can install Matplotlib using pip:
```sh
pip install matplotlib
```## Usage
Clone the repository and navigate to the project directory:
```sh
git clone https://github.com/username/bubble-sorting.git
cd bubble-sorting
```Run the script:
```sh
python main.py
```## Code Overview
### `BubbleSort` Class
- **`__init__`**: Initializes the Tkinter window, sets up the UI components (header, input field, button, result display, and footer).
- **`sort`**: Implements the Bubble Sort algorithm. Takes a list of integers and returns the sorted list along with the number of swaps made.
- **`print_result`**: Handles the button click event. Reads the input numbers, sorts them, updates the result label, and plots the original and sorted arrays using Matplotlib.
- **`run`**: Starts the Tkinter main loop to run the application.### Main Function
The main function creates an instance of the `BubbleSort` class and runs the application.
```python
def main():
bubble_sort = BubbleSort()
bubble_sort.run()if __name__ == "__main__":
main()
```## Example
After running the script, a window will appear where you can enter a list of numbers separated by commas (e.g., `3,1,4,1,5,9,2,6,5,3,5`). Clicking the "Sort" button will display the original and sorted arrays along with the number of swaps made. The arrays are visualized using bar charts.
## Author
Mehmet Kahya @mehmetkahya0
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.