Data Structure
CSE331
DR. HESHAM FARAG
Introduction
First, we have used python 3 as a programming language. Our
main goal is to plot the graph of steps of many important sorting
algorithms like insertion sort, merge sort, heap sort, counting
sort, quick Sort, bubble and radix Sort. Moreover, we will show
the notation of each algorithm, compare between steps of these
algorithms to know which is quicker and efficient. By making
such comparison, the uses and advantages of each algorithm will
be clearly displayed.
Code Illustration
Code Overview
[Link] and Purpose:
•plot_graphs.py: Handles graphing and visual representation
of sorting algorithm performance (steps, execution time,
complexity).
•[Link]: Defines constants like input sizes, sorting
scenarios, and algorithm complexities.
•[Link]: Generates test cases (random, sorted,
reversed arrays) and runs sorting tests.
•gui_app.py: Provides a GUI for interactive sorting algorithm
execution and visualization.
•sorting_algorithms.py: Implements sorting algorithms and
calculates steps for each sorting operation.
[Link] Flow:
•The GUI or [Link]() initiates the program.
•Arrays are generated ([Link]).
•Sorting algorithms process the arrays, recording steps and execution
times (sorting_algorithms.py).
•Results are stored in a CSV file and visualized via graphs
(plot_graphs.py).
[Link] Connections:
•[Link] depends on:
•[Link] for configurations.
•sorting_algorithms.py for algorithm logic.
•plot_graphs.py for visualization.
•gui_app.py provides a user interface for these features.
•plot_graphs.py uses matplotlib and seaborn for graph generation.
Main Application GUI
Compare page
in Compare page is called in each algorithm
to bind the needed x and y axes then this
function. And in GUI each button is set
command to use for each algorithm to get x
and y but wait until another one selected
and give them to compare_two_algorithms
( ).
Output:
Save Test Cases as CSV
The sorting algorithms tester GUI's "Save
Test Cases as CSV" button enables users
to export test results into a CSV file,
capturing algorithm names, steps, and
execution times, enabling easy
performance analysis, sharing, and
statistical evaluation.
Save Graph as PNG
The "Save Graph as PNG" button in the sorting
algorithms tester GUI provides a straightforward
way to export and save graphical
representations of sorting test results as PNG
images. This feature enables users to visually
capture and preserve the performance
comparison of different sorting algorithms, such
as steps taken and execution times, in a clear
and accessible format. By saving the graphs as
PNG files, users can easily include these
visuals in reports, presentations, or share them
for collaborative analysis, enhancing the
interpretability and presentation of the test data.
Algorithm Efficiency
Algorithm Efficiency in sorting algorithms is the efficiency of an
algorithm in terms of time and space utilization. Efficient
algorithms optimize these aspects to reduce computational
overhead and improve performance. Quick Sort and Merge
Sort offer better time efficiencies for large datasets, while
Bubble Sort may perform less efficiently due to costly methods.
Steps notation Comparison
"Steps Notation Comparison" evaluates the
number of operations a sorting algorithm takes to
sort an array, often in Big O notation. This helps
developers choose the most appropriate sorting
algorithm based on the specific needs of the
application, balancing performance and
computational resource usage.
Asymptotic Notation
Asymptotic Notation is a mathematical tool used
in computer science to describe algorithm
behavior as input size approaches infinity. It
provides a high-level understanding of an
algorithm's efficiency in terms of time and space
complexity. Common forms include Big O,
Theta, and Omega. Understanding asymptotic
notation is crucial for algorithm analysis and
informed software development decisions.
Comparing Algorithms Examples
This section compares the efficiency
and execution time of the sorting
algorithms. Through various tests, we
analyze how each algorithm performs
under different scenarios and with
different data sizes. Detailed graphs
and statistical analysis provide insight
into which algorithms are more
efficient.
Insertion sort
Merge sort
Heap Sort
Counting sort
Quick sort
Bubble sort
Radix sort
Selection sort
Example for each graph type
Conclusion
The project demonstrates the
varied performance of
different sorting algorithms.
Algorithms like Quick Sort
and Merge Sort showed the
best performance in most
scenarios, while algorithms
like Bubble Sort were less
efficient. Future work could
expand the dataset sizes and
include more complex
algorithms.