Report DAA Project (Sorting Visualizer)
Report DAA Project (Sorting Visualizer)
Report DAA Project (Sorting Visualizer)
Sorting Visualizer
Bachelor of Technology
in
Computer Science and Engineering
by
Affiliated to
CERTIFICATE
ACKNOWLEDGEMENT
We are highly indebted to Dr. Vinit Kumar for his guidance and
constant supervision. Also, we are highly thankful to them for
providing necessary information regarding the project & also for
their support in completing this project.
(Akshat Singh)
(Amogh Mishra)
(Abhay Garg)
ABSTRACT
The main goal of this project was to create a teaching support software with visualization of
the most known sorting algorithms and their variations. The application supports a graphic
visualization of selected algorithms on randomly generated or manually created array, step-
by-step execution possibility, pseudo-code and current state of variables.
This report outlines a study that tested the benefits of animated sorting algorithms for
teaching. To visualize four sorting algorithms, a web-based animation application was
constructed. A visualization of data is implemented as a bar graph, after which a data sorting
and algorithm may be applied. The resulting animation is then performed either automatically
or by the user, who then sets their own pace. This is a research on the computer science
curriculum's approach to learning algorithms. The experiment featured a presentation and a
survey, both of which asked students questions which may illustrate improvements in
algorithm comprehension. These findings and reactions are catalogued in this document and
compared to earlier investigations.
KEYWORDS: sorting algorithm; educational soft ware ; rea ct visualizer ; sel ection
sort; merge sort; bubbl e sort; insertion sort; heap so rt.
INDEX
1. INTRODUCTION
INTROUCTION TO PROJECT
PURPOSE OF THE PROJECT
EXISTING SYSTEM DESIGN
PROPOSED SYSTEM: IMPLEMENTATION
2. SYSTEM ANALYSIS
3. RESEARCH METHODOLOGY
WATERFALL METHODOLOGY
AGILE METHODOLOGY
FLOW CHART OF THE APPLICATION LOGIC
4. REQUIREMENT SPECIFICATIONS
SYSTEM REQUIREMENTS
PERFORMANCE REQUIREMENTS
5. SYSTEM DESIGN
INTRODUCTION
6. SYSTEM TESTING
UNIT TESTING
The main goal of the project was to create a program which would serve
as a tool for understanding how most known sorting algorithms work.
There was an attempt to make the best possible user experience. The
demonstration software is made in a user-friendly and easy-to-use style.
To gain maximal benefit from learning you can try each sorting algorithm
on your data.
The text of the report describes principles of the most known sorting
algorithms which are demonstrated in the computer program. It might be
used as a source for learning algorithms by students. Also, the program
might be easily used as a demonstration by lecturers and tutors during
classes. Besides, there is programmer documentation and user guide to
the provided software.
The design and structure of the user interface components has remained
unchanged even if the underlying back-end code was refactored midway
through the construction. Each component has its own feature: The
canvas has twelve features; 10 control buttons, and a volume toggle
button. The canvas area is where the four sorting algorithms are
visualized, and that area will be the location where the sorting algorithms'
output is edited in.
The first row of four blue-bordered buttons at the bottom of the canvas
are the selectable algorithms: Selection Sort, Bubble Sort, Insertion Sort,
and Merge/Insertion Sort. This type of visualization is offered to users to
select an algorithm of their choice, and to observe how that algorithm
functions. Before launching the animation, the user will need to select an
algorithm.
The sorting algorithm must be selected before the input data type is
specified. To choose between sorting input data that is already in order or
to reverse and randomize the order, the three gray-bordered buttons on
the left of the bottom row are available.
Sorted order is the default. The sorting algorithm is picked once the input
and sorting method have been selected. Following, the “Start” button in
the next row of buttons is clicked to perform the sort from the beginning
to the end.
The user can click the yellow-orange-bordered “Step” button to watch the
algorithm step-by-step. Once the process is already underway, you can
simply stop it by pressing the “Stop” button.
The colors are modeled on a traffic light with green being the go signal,
red being the stop signal, and yellow being the signal to slow down (or in
this case, yellow-orange means pace yourself). Additionally, each button
also provides visual feedback to the user by changing color as the cursor
hovers over it. The volume toggle button is the final function that is
available on the Web page. The button appears to the left of a speaker
picture on the lower left-hand side of the web page.
Before the final phase of development, the design was almost completely
functional, where only three objects were used: one to control the canvas
that displayed the animation, another to represent a piece of data, or “bar”
object (blue rectangle with dynamically changing height and position),
and a final one to represent the positions that each bar moved to, or “pos”
objects. Although this incorporated several function calls, some instance
variables and Boolean values were utilized to keep track of the algorithm
picked and when to animation, but this led to a greatly integrated mass of
code that was difficult to maintain.
Several big refactorings later, the code has now taken on the form of a
Model-View-Controller Architecture. Although, because of its functional
character, it possesses a multitude of individualized functions that alter
the instance variables and Boolean values, which means it has a multitude
of functions that directly alter the View and Controller. The major
module in the HTML code between the <script> and </script> tags is
known as the global scope. Everything within the framework is able to
access the aforementioned variables and methods.
The View
There are three items on the view: the sortArea, the bar, and the position.
These objects operate within the container defined by the <script> and
</script> tags in the .html file. This function's space is sometimes
referred to as the "main" function, the first function invoked in a program.
It is the sortArea that keeps the bars up to date using a timer, while at the
same time generating the bar graph. As a result, whenever "Step" is
invoked, the bar values are updated depending on the steps array
(discussed later). In the sortArea, after every second iteration of the timer,
the rectangles will be redrawn with varied heights that represent the new
values.
The bars change sixty times per second, so when the “Step” button is
selected, the change is instantaneous. In the sortArea, the bar object
represents each piece of data. The statement encompasses all of the
aspects of color, value, location, height, and sound. While having a
distinct array named bars for the current bars in the bar graph helps
preserve attributes such as the total number of bars (total value)
independent of other characteristics, it is simple to update any or all of the
attributes by iterating over the array as necessary.
The region on the canvas that is updated when the SortArea event fires is
an x-y pixel coordinate grid. This item was made to make arranging the
bars a little bit simpler (1-32). Thus, if I wanted to move a bar, I would
supply merely the number of the bar's location.
In order for the bar to move, it will first determine the exact coordinates
and then go to that location. Another way to say this is to say that,
position one is defined by the two-dimensional coordinate pair (9, 135),
which is the bottom left-hand corner of the bar. As long as each bar has a
rectangular object that is associated with it, as well as a top left-hand
corner point that defines the rectangle's height, the bar must be relocated
to its right location.
CHAPTER 2
SYSTEM ANALAYSIS
THE MODEL
The model is made up of one item, known as the sorter. This object
houses the algorithm's code divided into methods. Start method
centralizes on an integer constant and uses it to order the algorithm's
possible algorithms. This object is directly controlled by the four sorting
algorithms shown on the user interface as "Selection Sort, Bubble Sort,
Insertion Sort, and Merge/Insertion Sort." The sort algorithm method is
invoked as the user selects a sorting technique and clicks on one of the
sort algorithm buttons.
Then, when the algorithm sorts the data, a trace is created. The steps
array, which contains all the movements in the animation, is a two
dimensional integer array that is available to methods on the web user
interface. A typical back-end code interface is implemented using the
steps array. The “Start,” “Stop,” and “Step” buttons function as
controllers for which sub-array will be displayed on the canvas, after the
computational back-end has completed the tracing.
If this loads before the user has selected "Start" or "Step", then this
represents a user action. When you click the “Step” button, the next step
on the canvas loads and animates. An animated sequence of a single bar
moving across the others is produced because the timer continually
redraws the bars. There's no “Start” button, only a “Step” button that is
set to go off on a timer. Using a two-dimensional array gives you the
option to view the sorting algorithm's stages within the View.
The process of adding an algorithm is similar to writing down the trace of
the new algorithm, which is then saved in the same location. To complete
the algorithm's walkthrough, the View will cycle through the data and
update the bars in the bar graph to show how the algorithm calculated the
steps it took. It's important to note that if the algorithm generated a
change in the position of a piece of data, the steps are merely recorded.
Fig. View of Insertion Sorting
Let's give an example: When sorting the pieces of data using Selection
Sort, each piece of data is moved to its final and accurate location after
one step, whilst the others require numerous steps to get at their final
positions. While this sorting method appears to do the most effort
compared to other sorting methods, it finishes sorting the most slowly.
As a result, the visualization doesn't provide the correct visual impression
of the data comparisons, which is one of the most important aspects of
sorting algorithms. Two-dimensional arrays do demand more memory
than a one-dimensional array. The size of the array is based on the
number of steps that are required to sort the data.
We may assess the algorithm's space needs by examining how long it
takes. In Computer Science, using Big-Oh analysis is the standard way
for determining how long something will take. The notation consists of a
capital letter O, which represents the worst-case performance of the
algorithm in question, followed by a constraint in parentheses that
describes the worst-case performance of the algorithm.
Each package contains certain classes, which are grouped by the purpose
of use. Next subsections contain some general descriptions of the classes
from packages. More detailed descriptions of the class functions are
located directly in the source codes.
A Root Package
The root package contains only one class. It is MainUI.java. This class
serves as the main class which starts the application. Although JavaFX
provides the possibility of using XML-based language for creating a user
interface, here it is not used. The MainUI class defines main user
interface elements and does the instantiating of controllers.
All these three packages work with data and data structures, although a
bit differently. Constants package has only an eponymous class. This
class contains final static variables that are used as default values in the
program. Data package contains classes which serve as definitions for
data objects. BindingData class instance holds binding data for the
buttons from the control panel. Results class defines object that is used
for transferring results from the input dialog. Enum package contains one
definition of the enum class. Algorithm enum defines list of algorithms
that are visualized in the program. For example, a list with algorithm
names in the main window is generated from this enum.
Controllers package
NodeControllers package
We shall talk about them next. Before moving on, we describe node
managers generally. These objects are responsive for creation a visual
representation from the given data.
Also, they may create some additional graphic items, e.g. buckets for the
Bucket Sort. Node managers define animations for the certain types of
nodes and define their own metric system for certain type of nodes. The
first is DynamicNodes class. DynamicNodes object manages visual nodes
whose height depends on their value. Then, there is FixedNodes class.
This node manager class defines a manager that controls nodes of fixed
size. Finally, there is Tree node manager. Tree represents manager that
creates and controls a visual binary heap and corresponding visual array.
UI package
Utilities package
Algorithms package
And the last, but not the least significant, package called Algorithms. It
contains classes that actually do animating of the algorithms. Each class
that creates animations is supposed to extend Sorting class and implement
the AbstractAlgorithm interface. List of class definitions here
corresponds to the list of algorithms in the Algorithm enum.
Resources
Apart from the source code packages, project has a resource folder inside.
This folder contains images that are used in the program: icons, button
images. Also, it includes CSS files that are used for the styling of the
main window (style.css) and of the input dialog (dialog.css). In the
resource folder exists a subfolder that stores files with descriptions of the
algorithms. File names here correspond to the long names from the
Algorithm enum without spaces. Such name conventions help the reader
tool to find the right description.
CHAPTER 3
RESEARCH
METHODOLOGY
This section contains a description of the research methodologies
followed during the implementation of the project. The project was
implemented with a mixture of both Waterfall and Agile methodologies
often referred to as Hybrid Development methodology. Brief descriptions
of the methodologies are given below.
WATERFALL METHODOLOGY
The waterfall model is the first modern approach to the (SDLC) software
development life cycle model. The model describes the project
development in multiple sequential phases. Each phase track progress of
the project from multiple dimensions and the result of each phase act as
input for the next phase.
The flow chart below describes the logic of the application. It begins with
opening the application, then the user can see customizable settings in the
application UI. They can be changed, or the default setting can be used in
which case it will generate the steps of sorting for the default sorting
algorithm. To visualize the sorting process, all navigation buttons except
the “reset” button can be pressed or the “start” button for automatic
visualization. The reset button will generate the random array again. After
the visualization is complete, the process can be repeated, or the
application can be closed.
Since Java is cross-platform, you may use the application within the most
popular PC operating systems where Java is supported. Here are given
minimal system requirements for several operating systems.
Requirements:
Since Java applications are not native applications to the most popular
operating systems for PC9 , you need to have JDK10 or JRE11 installed
and configured. In case it is already done, it is enough to run the file of
the application with .jar extension as simple application.
Next opportunity is to run it through the command line. For Windows and
macOS it is done the same way. Type the command from below and add
the right path before the file name.
ja va −j a r So r ti ng−V i s u a l i z a t i o n . j a r
Just after running the application, the main window (Figure 12) shows up
and the application is ready to use.
CHAPTER 5
SYSTEM DESIGN
INTRODUCTION
HTML, CSS
CSS stands for Cascade Style Sheets. It is a tool used to add presentation
styles such as colors, layout, animations, and fonts to the web pages. It
allows the web pages to adapt to the different screen sizes across various
devices. CSS is independent of HTML thus it can also be used with any
XML-based markup language. CSS uses a selector to target the HTML
element and add styling to them. The CSS properties can be placed inside
the tag inside the tag of HTML file or it can be separated into a different
file with “.css” extension. Figure 7 below shows a basic HTML file with
CSS for styling.
The codes are written in a file with a “.ts” extension, any valid
JavaScript code is also TypeScript code, but TypeScript’s type
checking will point out errors that might cause possible type
mismatch and help minimize run time errors. The main aim of
TypeScript for building a JavaScript application is to avoid a
potential syntactical error that may cause runtime errors earlier
during the development phase. TypeScript also helps bring a
proper structure and documentation to the codebase and
scalability to the whole project. TypeScript is developed and
maintained by Microsoft.
SYSTEM TESTING
UNIT TESTING
Results
Start by arranging the data, and then pick the visualization algorithm to
use. Algorithm buttons provide sorting of data as it arrives on the
interface. Asking to specify the ordering of elements takes precedence
because when the algorithm has completed running the initialization
process, the interface is now showing a new ordering, while the code has
already completed running the initialization with the prior data set. There
was considerable confusion caused by the way the ordering buttons and
algorithm buttons were shown in the UI after the surveys were completed.
When beginning the sorting process, the student noted that she was
having problems starting because she believed that she was hitting the
buttons in the wrong order. This then led to her failing to execute the
animation.
Overall, our animation tool did not aid with the understanding of sorting
algorithms. Among those who answered question 3, which questioned if
their knowledge of a particular algorithm changed after using the tool, 5
of the 13 students (38%) stated that they had in some way altered their
previous knowledge of the algorithm. Many thought the tool was a good
concept, while the other 7 did not find it useful at all. It was said that one
student stated a false positive about the instrument (whom I did not
include in the 5 that said it was helpful).
Feedback
This is consistent with our prior research, which revealed that there was
no substantial difference in learning the content. What we do agree with
totally is the attitude that holds there is a great need to investigate and
produce animated presentations to enhance education in the classroom.
Overall, we are not concerned that a large rework to a different language
will be required soon because JavaScript is still one of the most popular
web languages.
We all know about my laundry list of upcoming projects, but there is one
elephant in the room that still has to be addressed: resolving the memory
difficulties. Following this, we would implement Merge/Insertion Sort,
which takes into account the Merge Sort. Then, we would start up Quick
Sort so as to finish the job because the code is ready to be integrated.
Finally, we would make the online tool available to the public, with the
feature we want most, which is to make it available to the public.
This might be tough as well. The application that created the animation
tool knows that it's available locally, but because of concurrency, it can
serve numerous requests to the web site by separate users. As we try to
figure out how to make the code as efficient as possible, we'd need to
spend some time thinking about how to make it work with numerous
people using it. This would be excellent, as it would enable a form of
comparison study.
REFERENCES
These sources include various research papers, related internet sites and
books.