Team19 Report
Team19 Report
Team 19
Trần Thị Loan–20215080
Lê Phương Nam –20210628
Vũ Đình Linh – 20194606
Chu Anh Lợi – 20215280
First, we would like to thank Ms. Nguyen Thi Thu Trang, our teacher, for her profound advice and
encouragement. Her expertise was instrumental in getting us on track and ensuring the success of our
project.
We would also like to thank Mr. Le Thanh Giang, teaching assistant, for his valuable contributions
and support throughout the project. His feedback and suggestions have played a vital role in improving
the overall quality of our work.
Together, we learned and grew through this project, and we would like to thank several of our
classmates for their time and effort in helping us answer some of the questions that supported our
report.
TABLE OF CONTENT
ACKNOWLEDGEMENT .................................................................................................................................. 2
TABLE OF CONTENT ...................................................................................................................................... 3
SUMMARY .................................................................................................................................................... 4
1. INTRODUCTION .................................................................................................................................... 5
2. ASSIGNMENT OF MEMBER ................................................................................................................... 6
3. MINI PROJECT DESCRIPTION ................................................................................................................ 7
3.1. Project Overview ......................................................................................................................... 7
3.2. Project Requirement ................................................................................................................... 7
3.3. Use case diagram and explanation .................................................................................................... 8
1. DESIGN ............................................................................................................................................... 10
1.1. General class diagram ............................................................................................................... 10
1.2. Detailed class diagram of each package ................................................................................... 12
1.2.1. Package sorting ..................................................................................................................... 12
1.2.2. Package mainMenuApplication ............................................................................................ 13
1.2.3. Class MainFrame of Package sortingApplication ................................................................. 14
1.2.4. Package bars ......................................................................................................................... 16
1.2.5. Package button ..................................................................................................................... 17
1.2.6. Package visualizer ................................................................................................................. 18
CONCLUSION .............................................................................................................................................. 20
SUMMARY
Our project is focused on visualizing three sorting algorithms – Merge Sort, Counting Sort, and
Radix Sort – through bar charts. The primary objectives are to fulfill our class assignments and develop a
practical Java Swing application. This application aims to provide a useful tool for programmers, allowing
them to visualize sorting algorithms in a colorful and interactive manner.
The report encapsulates the key aspects of our project, highlighting the contribution list, project
overview, and design. The overview section delves into the project's requirements and includes a use
case diagram illustrating the interaction between users and the application. The design section outlines
the overall structure of the project, detailing the relationships between different components. It
provides insights into each package, including classes, methods, attributes, and explanations of their
interconnections.
In conclusion, our report will also showcase the Object-Oriented Programming (OOP) techniques
employed throughout the project within the scope of our knowledge. This comprehensive summary
encapsulates the main points, objectives, and technical aspects of our endeavor.
1. INTRODUCTION
In the realm of Computer Science, sorting is a foundational concept indispensable for programmers.
It involves the arrangement of data sets sharing similar properties, and globally, diverse sorting
algorithms with distinct implementations and strategies have been devised. Nevertheless, the
comprehension of these algorithms can pose challenges, prompting the creation of a Java application as
a viable solution. This application serves to visualize the steps of three specific sorting algorithms: Merge
Sort, Counting Sort, and Radix Sort. The primary objective is to enhance accessibility and engagement in
understanding sorting algorithms, aligning with the requirements of our class mini-project.
This report meticulously examines every facet of our project, encompassing team assignments,
project descriptions, and design elements. The assignment segment acts as a grading guide, delineating
individual contributions and providing essential identification information for team members.
Furthermore, the project description elucidates features, requirements, and includes a use case diagram
with detailed explanations and notes. The design section offers an encompassing perspective through a
general class diagram and scrutinizes each package within it, presenting methods, attributes, and
showcasing the application of Object-Oriented Programming (OOP) techniques employed in the project
2. ASSIGNMENT OF MEMBER
Member Tran Thi Loan(Leader) Le Phuong Nam Vu Dinh Linh Chu Anh Loi
Due to the main purpose of visualization is to help users get a better insight into how an algorithm
works, we have put some restrictions on our application:
2. The array size used for visualization has a max size of 200 elements.
3. A valid array in Radix Sort, Merge Sort, Counting Sort only has the max value is form 30 to 350.
1. On the main menu: The main menu is designed to provide users with a simple and intuitive way
to navigate through the sorting visualizer application. The components of the interface include:
- Title Label:Positioned at the top of the interface, it prominently displays the application's title,
"Sorting Visualizer," in a bold and large font.
- Sort Button:Labeled "Sort," this button allows users to initiate the sorting demonstration. Upon
clicking, it opens a new frame (MainFrame) for the selected sorting algorithm, and the current menu
frame is disposed of.
- Help Button:Labeled "Help," this button triggers the display of a help dialog providing users with
essential information about sorting algorithms and the functionality of the application.
- Quit Button:Labeled "Quit," this button prompts users with a confirmation dialog before exiting
the application. If the user confirms, the application is terminated using System.exit(0).
2. In the demonstration:
In the sorting demonstration interface, users are presented with various components allowing for
interactive exploration and visualization of sorting algorithms.
- Back to Menu Button: Located at the top-left corner, this button enables users to return to the
main menu, offering seamless navigation between the sorting demonstration and the main application.
- Buttons Panel: Positioned on the left side, the buttons panel provides a set of controls for the user
to interact with the sorting algorithms. Options include creating a random array and selecting different
sorting algorithms such as Radix Sort, Counting Sort, Merge Sort, and a back button to return to the
main menu.
- Canvas: Serving as the visualization area for the sorting algorithms. It dynamically adjusts its size
based on the available space.
- Input Fields and Sliders: Include input fields for adjusting the capacity of the array and a slider for
controlling the frames per second (FPS) to regulate the speed of the sorting visualization.
- Statistics Panel: Displays real-time statistics such as elapsed time, the number of comparisons, and
the number of swaps during the sorting process. These statistics provide valuable insights into the
efficiency and performance of the chosen sorting algorithm.
* User Interaction: The sorting demonstration interface encourages user engagement and exploration.
Users can create random arrays, select different sorting algorithms, and observe the step-by-step
visualization of the sorting process. The interactive components, including buttons and sliders, provide
users with control over the demonstration's parameters, enhancing the learning experience.
Based on all the requirements we decided to develop five use cases (as shown in the figure for our
application.)
To be more specific:
- Choose sort algorithm: Allow the user to choose an algorithm to sort with an array.
- Generate Data: Allow the user to create random array by the leftside button
+ Run the visualization based on user command and see the steps in the sorting process
- View help menu uses case: Show the user manual and application restriction to the user under.
- Back to the main menu and quit : Backward to the main menu and exit the application.
1. DESIGN
1.1. General class diagram
Screen to
visualize
MainFrame + MainFrame() Override method
sorting
onArraySorted,
algorithms - initialize() : void
getBufferStrategy,
+ propertyChange(e : int) : void sortButtonClicked
and onDrawArray
+ stateChange(e : int) : void
+ onDrawArray() : void
+onArraySorted(elapsedTime: long,
comp : int, swapping : int) : void
+ getBufferStrategy() : int
Displays real-
time
SortedListener + onArraySorted(elapsedTime :
statistics
long, comparison : int, swapping :
such as
int) : void
elapsed
time, the + getBufferStrategy() : int
number of
comparisons,
and the
number of
swaps during
the sorting
process.
+ getValue() : int
+ setColor(color :
int) : void
+ getColor() : int
1.2.5. Package button
- + createRandomArray(canvasWidth : int,
MAX_BAR_HEIGHT canvasHeight : int) : void
: int = 350
- getBarColor(value : int) : int
- MIN_BAR_HEIGHT
+ selectionSort() : void
: int = 30
- getMax(arr : int[], n : int, exp : int, comp : int)
- array : int[]
: void
- capacity : int + radixSort() : void
+ drawArray() : void
- isCreated() : boolean
The application exhibits a well-organized design structured into five main packages. Throughout the
implementation, several Object-Oriented Programming (OOP) techniques such as Inheritance,
Polymorphism, Aggregation, and Composition have been employed within the scope of our knowledge.
Despite its success, the project still presents ample opportunities for enhancement. Areas for
improvement include User Interface (UI) design, accessibility, application logic, performance optimization,
and tool integration. Visualization serves as a crucial means of communication between algorithms and
programmers. The overarching goal now is to further develop the project, aiming to attract a broader
audience and facilitate a deeper understanding of these abstract algorithmic concepts.