Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

ALGORITHM VISUALIZER

PROJECT REPORT
OF MAJOR PROJECT

BACHELOR OF TECHNOLOGY

CSE

SUBMITTED BY

Prabhjot Singh Parampreet Singh

Roll No. 2002559 Roll No. 2002552

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Chandigarh Engineering College – Landran

Mohali, Punjab – 140307


August, 2022

pg. 1
Index

Page No.
Topic

1. Abstract 4

2. Introduction 4

3. Related Work 5

4. Literature Survey 6

5. Methodology & Planning 7

6. Requirements 8

pg. 2
7. Results 8

8. Future Scope 9

9. Conclusions 9

10. References 9

11. Source Code 10

12. Output 15

pg. 3
1. Abstract

This paper 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 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.

2. Introduction

Data structure and algorithm visualizations and animations (hereafter referred to generically as
algorithm visualizations) have a long history in computer science education. While the 1981 video
“Sorting out Sorting” by Ronald Permission to make digital or hard copies of all or part of this work
for personal or classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation on the first
page.

To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee. Baeker was the first well-known visualization, ad hoc visualizations existed
long before. The first recognized system for creating algorithm animations was BALSA [2] in 1984.
Since then, hundreds of algorithm visualizations have been implemented and provided freely to
educators, and scores (or hundreds) of papers have been written about them.

It is widely perceived that algorithm visualizations can provide a powerful alternative to static written
presentations (from textbooks) or verbal descriptions supported by illustrations (from lectures). There
has been some debate in the literature as to whether algorithm visualizations are effective in practice.
Some studies have shown the classic dismissal that is the downfall of most technological interventions
in education: “no significant difference” [6, 9, 11].

Other studies have shown that algorithm visualizations can indeed improve understanding of the
fundamental data structures and algorithms that are part of a traditional computer science curriculum
[13, 3, 7]. Certainly, many visualizations exist and are widely (and freely) available via the Internet.
Unfortunately, the vast majority of those currently available serve no useful pedagogical purpose. So
we see that (a) many algorithm visualizations exist, yet relatively few are of true value, and (b)
algorithm visualizations can be demonstrated to have pedagogical value, yet it is also quite possible to
use them in ways that have no pedagogical effect.

These facts seem to imply that creating and deploying effective algorithm visualizations is difficult.
There is a small body of literature that investigates how to create pedagogically useful algorithm
visualizations (for example, [10, 15]). Yet, there is still much to be done before we are at the point
where good quality visualizations on most topics of interest are widely available.

pg. 4
3. Related Work
How do you get something done? You don't have to be extremely complex in solving the problem, for
example, if your car's headlight is broken (although nowadays, manufacturers are trying the patience
of the community with their increasingly abstract, space-age designs). The main issue is figuring out
the best way to go about it.
To locate step-by-step directions in your car's handbook, you conduct research, or do you use instinct
to find someone who knows how to do it?

In short, my instinct tells me that I am a visual learner and hence more suited to acquire topics by
watching them than by reading about them. In this case, I found that seeing the data move to its
rightful spot as the result of an algorithm is MUCH easier to follow than looking at the source code
and trying to figure out where the data was supposed to go.

My project was born out of my curiosity about sorting algorithms, which inspired the idea for this
paper, which details an online tool I built that explains how sorting algorithms transform and organize
sets of data. It is possible to organize a list of people, for example, by their age in ascending order
using different methods.

To aid my visualization, I created a histogram of numerical data to represent four of the well-known
examples. Each number is depicted as a bar, and the height of each bar represents the value of that
number. It is being shifted by the algorithm from its original, unordered location to its final ordered
place, making it distinct from the rest of the data.

Selection Sort, Bubble Sort, Insertion Sort, and Merge Sort are the four sorting algorithms. 2 Let's
imagine that you have printed each person's age on a separate index card. Bring the youngest card to
the front and then sort the cards by age. To discover the next smallest item, identify the age that has
already been ordered and position it behind the already ordered age.

Index cards full of ages will be at the end of the pile. Selection Sort works in the same way as this. In
this case, to sort a set of data, you select the smallest first, and then the next smallest, and so on until
you've sorted all of the data.

This technique is quite simple to explain to someone in conversation, but more advanced sorting
algorithms, such as Quick Sort, which requires the data to be moved around a pivot point, are not easy
to grasp using text alone.

4. Literature Survey

pg. 5
A computer primarily based approach for performing a command via a voice consumer
interface on a subset of objects. The subset is selected from a fixed of items, each
having an object type at least one taggable field is associated with the object type and
has a corresponding value. The set of objects is saved in the laptop memory. An
utterance is acquired from the person and consists of a command, an object type choice,
a tag-gable field selection, and a price for the taggable discipline. Responsive to the
utterance, at least one item is retrieved from the set of gadgets, the item of the sort
selected through the user and having a price within the taggable area selection that
matches the taggable field fee obtained from the user the command is done on the item.
The object includes textual content that’s converted to voice output [1]. They envi-
sioned that someday computers will recognize natural language and count on what we
need, whilst and where we need it, and proactively whole responsibilities on our behalf.
However, speech recognition and machine getting to know have persevered to be
refined, and based records served through packages and content providers have
emerged. We agree with that as computer systems turn out to be smaller and greater
ubiquitous [e.g., wearable’s and Internet of Things (IoT) [2]. The recognizer is
designed to change a verbal articulation from a individual into an alternate method of
data (e.g., text). A hand held individual colleague including a voice-recognizer and a
characteristic dialect processor is disclosed. This snippet of data can be a plan for the
day, data in the individual’s logbook or data from the individual’s address book, Such
as a telephone number [3].
The Most well known utilization of iPhone is “SIRI” which causes the end client to
impart end client versatile with voice and it additionally reacts to the voice charges of
the client. It is named as Personal Assistant with Voice Recognition Intelligence, which
takes the client contribution to type of voice or content and process it and returns the
yield in different structures like activity to be performed or the item is directed to the
end client. Furthermore, this proposed framework can change the method for com-
munications between end client and the cell phones [4]. Open Data is currently
gathering consideration for imaginative administration creation, predominantly in the
zone of government, bio science, and shrewd venture. Be that as it may, to advance its
application more for purchaser administrations, a web crawler for Open Data to realize
what sort of information is there would be of assistance.
This paper presents a voice colleague which utilizes Open Data as its learning
source. It is highlighted by change of precision as per the client criticisms, and
obtaining of unregistered information by the client support. We additionally demon-
strate an application to help for a field-work and affirm its viability [5]. The paper gives
a diagram of the VPA applications, and the normal highlights and future patterns. The
paper proposes also a bound together choice model in light of a quantitative appraisal
of the significance of the solicitations and the accessibility of the client. Virtual Per-
sonal Assistant (VPA) is the up and coming age of bearer administrations for portable
clients. VPA is accepted to be the smart advancement of administrations to take care of
the regularly expanding demand by the portable experts for portability and network.
The VPA controls the phone calls, deals with the individual exercises through logbook,
192 A. S. Tulshan and S. N. Dhage
A computer primarily based approach for performing a command via a voice consumer
interface on a subset of objects. The subset is selected from a fixed of items, each
having an object type at least one taggable field is associated with the object type and
has a corresponding value. The set of objects is saved in the laptop memory. An
utterance is acquired from the person and consists of a command, an object type choice,
a tag-gable field selection, and a price for the taggable discipline. Responsive to the
utterance, at least one item is retrieved from the set of gadgets, the item of the sort

pg. 6
selected through the user and having a price within the taggable area selection that
matches the taggable field fee obtained from the user the command is done on the item.
The object includes textual content that’s converted to voice output [1]. They envi-
sioned that someday computers will recognize natural language and count on what we
need, whilst and where we need it, and proactively whole responsibilities on our behalf.
However, speech recognition and machine getting to know have persevered to be
refined, and based records served through packages and content providers have
emerged. We agree with that as computer systems turn out to be smaller and greater
ubiquitous [e.g., wearable’s and Internet of Things (IoT) [2]. The recognizer is
designed to change a verbal articulation from a individual into an alternate method of
data (e.g., text). A hand held individual colleague including a voice-recognizer and a
characteristic dialect processor is disclosed. This snippet of data can be a plan for the
day, data in the individual’s logbook or data from the individual’s address book, Such
as a telephone number [3].
The Most well known utilization of iPhone is “SIRI” which causes the end client to
impart end client versatile with voice and it additionally reacts to the voice charges of
the client. It is named as Personal Assistant with Voice Recognition Intelligence, which
takes the client contribution to type of voice or content and process it and returns the
yield in different structures like activity to be performed or the item is directed to the
end client. Furthermore, this proposed framework can change the method for com-
munications between end client and the cell phones [4]. Open Data is currently
gathering consideration for imaginative administration creation, predominantly in the
zone of government, bio science, and shrewd venture. Be that as it may, to advance its
application more for purchaser administrations, a web crawler for Open Data to realize
what sort of information is there would be of assistance.
This paper presents a voice colleague which utilizes Open Data as its learning
source. It is highlighted by change of precision as per the client criticisms, and
obtaining of unregistered information by the client support. We additionally demon-
strate an application to help for a field-work and affirm its viability [5]. The paper gives
a diagram of the VPA applications, and the normal highlights and future patterns. The
paper proposes also a bound together choice model in light of a quantitative appraisal
of the significance of the solicitations and the accessibility of the client. Virtual Per-
sonal Assistant (VPA) is the up and coming age of bearer administrations for portable
clients. VPA is accepted to be the smart advancement of administrations to take care of
the regularly expanding demand by the portable experts for portability and network.
The VPA controls the phone calls, deals with the individual exercises through logbook,
192 A. S. Tulshan and S. N. Dhage
The purpose of this paper is to provide a summary of preliminary findings resulting from our efforts to
survey the state of the field of algorithm visualization.
To bound the content area, we focused our attention on topics commonly taught in undergraduate
courses on data structures and algorithms.

We seek an understanding of the overall health of the field, and present a number of open research
questions that we and others can work on in the future. Since Spring 2006, we have made a significant
effort to catalog as many existing algorithm animations as we could.

The results can be found at our Data Structure and Algorithm Visualization Wiki [18].
In this time, we have developed the most extensive collection of links to algorithm visualizations
currently available. While it is by no means complete, it does serve as a representative sample of the
total population of visualizations accessible from the Internet.

pg. 7
We are still collecting visualizations, and many of the following assessments are based on preliminary
data. We used a number of techniques to locate algorithm visualizations.

We began with a list of all visualization systems that we were aware of from our general knowledge of
the field. We developed a topic list based on our experiences teaching relevant courses.
We considered what search terms would be most productive for locating visualizations via Internet
searches (this is discussed further in Section 3).

Based on our topic list, we then performed searches using Google to find whatever we could.
Once we had generated a base of visualization links, we then examined these pages to try to locate
other visualizations, since developers of a given visualization often have others available.

Sometimes we could find these other visualizations from direct references on the pages we already
had, and other times we could deconstruct the URLs to find more visualizations.

Whenever we stumbled across a page that had links to collections of visualizations, we would follow
those links to capture any new ones not yet in our collection. We have collected links to over 350
visualizations.

Many of these are individual applets or programs, but a significant fraction appear as parts of
integrated visualization collections (typically, individual applications that include 5-20 distinct
visualizations, or toolkits that distribute a collection of 5-20 distinct visualizations as a unit).
If a given program contains multiple visualizations (for example, a single Java applet that embodies
separate visualizations for both stacks and queues), then we count it multiple times, once for each
distinct visualization. We speculate that we have so far captured roughly half of what is publicly
available.

empowers the client to get to his undertaking administrator by means of voice inter-
faces, and incorporates every one of the elements of Unified Messaging. The Virtual
Personal Assistant (VPA) will empower the client to productively handle expanding
interest of phone calls, messages, gatherings and different exercises [6].
In any case, a great many people don’t utilize them consistently. Past research has
examined the encounters of continuous IPA clients. Utilizing subjective techniques we
investigate the experience of rare clients: individuals who have attempted IPAs, yet
pick not to utilize them consistently. Obviously occasional clients share a portion of the
encounters of successive clients, e.g. dissatisfaction at confinements on completely sans
hands collaboration. Critical purposes of difference and beforehand unidentified con-
cerns likewise develop. Humanness of IPAs started correlations with human associates,
comparing their restrictions. In particular, critical concerns rose around security,
adaptation, information permanency and straight forwardness. Drawing on these dis-
coveries we talk about key difficulties, including: outlining for interrupt ability; re-

pg. 8
examination of the human similitude; issues of trust and information proprietor-
ship. Tending to these difficulties may prompt more across the board IPA utilize [7].
As virtual assistants move toward becoming more intelligent and the IVA bio-
logical community of administrations and gadgets extends, there’s a developing need to
comprehend the security and protection dangers from this rising innovation. A few late
occurrences feature noteworthy vulnerabilities in IVAs. Better demonstrative testing
can uncover such vulnerabilities and prompt more reliable frameworks [8]. It enables
the objective clients to connect with PCs and web based administrations with a wide
cluster of usefulness in light of different web administrations and social media. There
are four standard parts of the system; the voice recognition module, the natural lan-
guage processing module, conversational agent and the content extraction module. The
current screen per client writing computer programs are not fitting for getting to
Internet in perspective of the base help they give for web content and the nonattendance
of voice affirmation. The Virtual Right hand programming open in the market are not
especially given everything and unfit to utilize it similarly. Some may confront issue
now too [9].
This paper presents a usability of four Virtual assistant voic-baesd and contextual
text (Google assistant, Coratan, Siri, Alexa) [10]. Cortana can likewise read your
messages, track your area, watch your perusing history, check your contact list, watch
out for your date-book, and set up this information together to propose valuable data,
on the off chance that you enable it. You can likewise type your inquiries or solici-
tations, in the event that you want to not stand up uproarious. It is only desktop based
virtual assistant. [11] Siri: Siri has been an integral part of iOS since the dispatch of iOS
5 of every 2011. It began with the nuts and bolts, for example, climate and informing,
yet has extended significantly from that point forward to help all the more outsider mix
with MacOS. While Siri’s jokes are unbelievable, the virtual aide is getting more able
consistently. Presently, you can request that it call individuals, send messages, plan
gatherings, dispatch applications and recreations, and play music, answer questions, set
updates, and give climate conjectures [12]. Google Assistant: Google Assistant (which
has consolidated capacities from the more seasoned Google now, as now is being
eliminated) is unique in relation to Cortana and Siri.
Survey on Virtual Assistant: Google Assistant, Siri, Cortana, Alexa 1
The significantly conversational VA is capable at interpreting essential vernaculars
and understanding the importance behind unobtrusively complex request like, “What
should we have for dinner?” It can in like manner see up to six unmistakable voices for
couples and families, each voice settling to different logbook events and slants, great
position amazing to Assistant and impeccable in a condition where everyone uses the
voice helper on a singular gadget [13]. Alexa: While sharing different features similarly
as various VAs, Alexa is in its own one of a kind class. Amazon’s voice partner isn’t
centred on portable or PC purposes, but instead for the independent Amazon Echo
speaker and a set number of Amazon Fire gadgets, with a more prominent focus on
entire house administration and administrations as opposed to PC situated errands [14].
Each business visionary, side trickster and multitasking proficient out there would love
to have a virtual assistant right hand to go up against a portion of the dull every day
errands that accompany existing in the advanced time.
Similarly as with any developing innovation, in any case, it can be hard to isolate
the build up from the certainties. There are four noteworthy players seeking consid-
eration: Amazon (Alexa), Apple (Siri), (Google Assistant) and Microsoft (Cortana).
I invested hours testing each of the four assistants by making inquiries and giving
charges that numerous business clients would utilize [15]. Amid the testing procedure, I
noticed the accomplishment of the AI’s reaction to me, and in addition different

pg. 9
components a planned users may think about, for example, simplicity of setup, general
capacity to perceive my voice and relevant comprehension. About each cell phone and
PC available today has a brilliant right hand caught inside, similar to an accommo-
dating phantom—however how might they stack up against each other? While it may
seem like Siri, Cortana, and the mysterious Google Assistant are in general just
assortments of the same virtual partners, they each have their own specific uncon-
ventionality’s, imperfections, and characteristics. So which one’s best for clients? All
things considered, that isn’t a basic request to answer, as they’re like the point that it’s
hard to take a gander at them without plunging significant into their capacities. Along
these lines, we should start on this virtual right hand connect
empowers the client to get to his undertaking administrator by means of voice inter-
faces, and incorporates every one of the elements of Unified Messaging. The Virtual
Personal Assistant (VPA) will empower the client to productively handle expanding
interest of phone calls, messages, gatherings and different exercises [6].
In any case, a great many people don’t utilize them consistently. Past research has
examined the encounters of continuous IPA clients. Utilizing subjective techniques we
investigate the experience of rare clients: individuals who have attempted IPAs, yet
pick not to utilize them consistently. Obviously occasional clients share a portion of the
encounters of successive clients, e.g. dissatisfaction at confinements on completely sans
hands collaboration. Critical purposes of difference and beforehand unidentified con-
cerns likewise develop. Humanness of IPAs started correlations with human associates,
comparing their restrictions. In particular, critical concerns rose around security,
adaptation, information permanency and straight forwardness. Drawing on these dis-
coveries we talk about key difficulties, including: outlining for interrupt ability; re-
examination of the human similitude; issues of trust and information proprietor-
ship. Tending to these difficulties may prompt more across the board IPA utilize [7].
As virtual assistants move toward becoming more intelligent and the IVA bio-
logical community of administrations and gadgets extends, there’s a developing need to
comprehend the security and protection dangers from this rising innovation. A few late
occurrences feature noteworthy vulnerabilities in IVAs. Better demonstrative testing
can uncover such vulnerabilities and prompt more reliable frameworks [8]. It enables
the objective clients to connect with PCs and web based administrations with a wide
cluster of usefulness in light of different web administrations and social media. There
are four standard parts of the system; the voice recognition module, the natural lan-
guage processing module, conversational agent and the content extraction module. The
current screen per client writing computer programs are not fitting for getting to
Internet in perspective of the base help they give for web content and the nonattendance
of voice affirmation. The Virtual Right hand programming open in the market are not
especially given everything and unfit to utilize it similarly. Some may confront issue
now too [9].
This paper presents a usability of four Virtual assistant voic-baesd and contextual
text (Google assistant, Coratan, Siri, Alexa) [10]. Cortana can likewise read your
messages, track your area, watch your perusing history, check your contact list, watch
out for your date-book, and set up this information together to propose valuable data,
on the off chance that you enable it. You can likewise type your inquiries or solici-
tations, in the event that you want to not stand up uproarious. It is only desktop based
virtual assistant. [11] Siri: Siri has been an integral part of iOS since the dispatch of iOS
5 of every 2011. It began with the nuts and bolts, for example, climate and informing,
yet has extended significantly from that point forward to help all the more outsider mix
with MacOS. While Siri’s jokes are unbelievable, the virtual aide is getting more able
consistently. Presently, you can request that it call individuals, send messages, plan

pg. 10
gatherings, dispatch applications and recreations, and play music, answer questions, set
updates, and give climate conjectures [12]. Google Assistant: Google Assistant (which
has consolidated capacities from the more seasoned Google now, as now is being
eliminated) is unique in relation to Cortana and Siri.
Survey on Virtual Assistant: Google Assistant, Siri, Cortana, Alexa
The significantly conversational VA is capable at interpreting essential vernaculars
and understanding the importance behind unobtrusively complex request like, “What
should we have for dinner?” It can in like manner see up to six unmistakable voices for
couples and families, each voice settling to different logbook events and slants, great
position amazing to Assistant and impeccable in a condition where everyone uses the
voice helper on a singular gadget [13]. Alexa: While sharing different features similarly
as various VAs, Alexa is in its own one of a kind class. Amazon’s voice partner isn’t
centred on portable or PC purposes, but instead for the independent Amazon Echo
speaker and a set number of Amazon Fire gadgets, with a more prominent focus on
entire house administration and administrations as opposed to PC situated errands [14].
Each business visionary, side trickster and multitasking proficient out there would love
to have a virtual assistant right hand to go up against a portion of the dull every day
errands that accompany existing in the advanced time.
Similarly as with any developing innovation, in any case, it can be hard to isolate
the build up from the certainties. There are four noteworthy players seeking consid-
eration: Amazon (Alexa), Apple (Siri), (Google Assistant) and Microsoft (Cortana).
I invested hours testing each of the four assistants by making inquiries and giving
charges that numerous business clients would utilize [15]. Amid the testing procedure, I
noticed the accomplishment of the AI’s reaction to me, and in addition different
components a planned users may think about, for example, simplicity of setup, general
capacity to perceive my voice and relevant comprehension. About each cell phone and
PC available today has a brilliant right hand caught inside, similar to an accommo-
dating phantom—however how might they stack up against each other? While it may
seem like Siri, Cortana, and the mysterious Google Assistant are in general just
assortments of the same virtual partners, they each have their own specific uncon-
ventionality’s, imperfections, and characteristics. So which one’s best for clients? All
things considered, that isn’t a basic request to answer, as they’re like the point that it’s
hard to take a gander at them without plunging significant into their capacities. Along
these lines, we should start on this virtual right hand connectProposed Plan Of Work
5. Methodology & Planning
In this article, we will build a Sorting Algorithm Visualizer using Python and Tkinter.
Tkinter is a standard GUI library for Python. We will use it to create the user interface of our
project. We will visualize Bubble Sort and Merge Sort. But we can implement all the
comparisonbased sorting algorithms in this project.
Table of Contents:
· File Structure of the Project
· colors.py
· main.py
· Filling up The Functions
· Implementing Bubble Sort
· Implementing Merge Sort
· Completing what we left behind

pg. 11
We will structure our project files at the very beginning. First, we will create a folder and name
it Sorting Visualizer. This will be our project directory. Inside this folder, we will create
another folder named algorithms.

Then we will create two python files main.py and colors.py. main.py will be our main Python
file which we will execute. colors.py will contain some hexadecimal values of colors that we
will need. Inside the algorithm folder, we will create a file __init__.py.

This will allow the algorithms folder to act as a Python package. See the documentation on
packaging a project. We will create two more Python files inside the algorithms folder,
bubbleSort.py and mergeSort.py. In these files, we will implement our sorting algorithms.So
our file structure will be like this…

In colors.py we will store some hexadecimal values of colours as variables. We will


use these colours in our project. main.py will be our main executable file that will run our
project. We will import all packages and modules in this file.
First, we will import some stuff and set up a basic interface.

6. Requirements
Hardware Requirements:
Processor- dual core 2.4 GHz (i5 or i7 series Intel processor or equivalent AMD)
RAM-4GB

Software Requirements:
Python
Visual Studio Code
PIP 2.7
Operating system- Windows 7,8,10

pg. 12
7. Results
• We conducted a survey to find out if there is any considerable impact in the people willing to
choose the Algorithm Visualizer application with the proposed features. To our delight we
found 10% increase in the overall survey result, that is, now 70% people are willing to refer to
algorithm visualizer application with improved features for understanding algorithms as
compared to 60% of last time .

• It has been found by researchers and scholars that when people try to memorize something in
the form of a storyline or relating that aspect with daily lives then they are more likely to retain
it for long period of time. Thus, the additional features will make the students retail the
concepts for long and guide them to becoming specialists in this domain.

• Moreover, relating the concepts learnt in course curriculums to real life examples will
develop a research perspective in students and knowing the actual working of anything around
them will turn out to be their habit, thus, contributing to their knowledge.

• This improved application would enable the teachers to explain difficult topics with ease
thus, helping them get off the burden. Also, the teachers themselves can come up with
innovative ways of visualizations that can help improve the application’s performance from
time to time.

pg. 13
8. Future Scope
. So, we built an application which could help in the following ways: -

• It has been found that it becomes easier for humans to retain the concepts when learnt through
visuals than just textual or speech explanations.

• Application is extremely user friendly so people of any age can engage and start learning new things
right away. The application would also include various fun filled activities like visualization through
mazes and patterns.

• This application will also include a parameter of time complexity which will be displayed after the
particular sorting algorithm has completed its execution for better comparison.

• Almost all the famous and important algorithms will be present in the application for visualization
with both path-finding and sorting algorithms present in same application, thus making it a one stop
destination for the students of this domain

• With the inclusion of the proposed features, the algorithm would not only help in better
visualization and retention of concepts by students, but also, enable the students have a gradual and
smooth transition from school level to college level of education, thus, enhancing their knowledge and
productivity

9. Conclusion

In a nutshell, we identify some issues by experiencing them ourselves in the present learning strategies
in use and we tried to help better the scenario for aspiring students in this domain through or
progressive web application. When we ourselves were learning the subject of algorithms in our
curriculum, we found it a bit difficult to relate and understand the practical implementation of the
algorithms owing to the difficulty in communication of the concepts from the teachers to the students.
We found that there were no proper means that the teachers could adopt to portray their ideas in a
better and easy manner in front of the students.

10. References
[1] Association for Computing Machinery. The ACM digital library. http://portal.acm.org, 2006.
[2] M. H. Brown and R. Sedgewick. A system for algorithm animation. In SIGGRAPH ’84:
Proceedings of the 11th Annual Conference on Computer Graphics and Interactive Techniques, pages
177–186, New York, NY, USA, 1984. ACM Press.
[3] M. D. Byrne, R. Catrambone, and J. T. Stasko. Do algorithm animations aid learning? Technical
Report GIT-GVU-96-18, Georgia Institute of Technology, 1996.
[4] CITIDEL: Computing and information technology interactive digital educational library. http://
www.citdel.org, 2006.
[5] Connexions scholarly content repository. http:// cnx.org, 2006.
[6] J. S. Gurka and W. Citrin. Testing effectiveness of algorithm animation. In Proceedings, IEEE
Symposium on Visual Languages, pages 182–189, 1996.
pg. 14
11. Source Code:

import tkinter as tk
import random

#Function to swap two bars that will be animated


def swap(pos_0, pos_1):
    bar11, _, bar12, _ = canvas.coords(pos_0)
    bar21, _, bar22, _ = canvas.coords(pos_1)
    canvas.move(pos_0, bar21-bar11, 0)
    canvas.move(pos_1, bar12-bar22, 0)

worker = None

#Insertion Sort
def _insertion_sort():
    global barList
    global lengthList

    for i in range(len(lengthList)):
        cursor = lengthList[i]
        cursorBar = barList[i]
        pos = i

        while pos > 0 and lengthList[pos - 1] > cursor:


            lengthList[pos] = lengthList[pos - 1]
            barList[pos], barList[pos - 1] = barList[pos - 1], barList[pos]
            swap(barList[pos],barList[pos-1])  
            yield                                      
            pos -= 1                                  

pg. 15
        lengthList[pos] = cursor
        barList[pos] = cursorBar
        swap(barList[pos],cursorBar)

#Bubble Sort
def _bubble_sort():
    global barList
    global lengthList
  
    for i in range(len(lengthList) - 1):
        for j in range(len(lengthList) - i - 1):
            if(lengthList[j] > lengthList[j + 1]):
                lengthList[j] , lengthList[j + 1] = lengthList[j + 1] , lengthList[j]
                barList[j], barList[j + 1] = barList[j + 1] , barList[j]
                swap(barList[j + 1] , barList[j])
                yield        
      

#Selection Sort            
def _selection_sort():
    global barList    
    global lengthList

    for i in range(len(lengthList)):
        min = i
        for j in range(i + 1 ,len(lengthList)):
            if(lengthList[j] < lengthList[min]):
                min = j
        lengthList[min], lengthList[i] = lengthList[i] ,lengthList[min]
        barList[min] , barList[i] = barList[i] , barList[min]

pg. 16
        swap(barList[min] , barList[i])        
        yield

#Triggering Fuctions

def insertion_sort():    
    global worker
    worker = _insertion_sort()
    animate()

def selection_sort():    
    global worker
    worker = _selection_sort()
    animate()

def bubble_sort():    
    global worker
    worker = _bubble_sort()
    animate()    

#Animation Function
def animate():      
    global worker
    if worker is not None:
        try:
            next(worker)
            window.after(10, animate)    
        except StopIteration:            
            worker = None
        finally:
            window.after_cancel(animate)
pg. 17
#Generator function for generating data
def generate():
    global barList
    global lengthList
    canvas.delete('all')
    barstart = 5
    barend = 15
    barList = []
    lengthList = []

    #Creating a rectangle
    for bar in range(1, 60):
        randomY = random.randint(1, 360)
        bar = canvas.create_rectangle(barstart, randomY, barend, 365, fill='yellow')
        barList.append(bar)
        barstart += 10
        barend += 10

    #Getting length of the bar and appending into length list


    for bar in barList:
        bar = canvas.coords(bar)
        length = bar[3] - bar[1]
        lengthList.append(length)

    #Maximum is colored Red


    #Minimum is colored Black
    for i in range(len(lengthList)-1):
        if lengthList[i] == min(lengthList):
            canvas.itemconfig(barList[i], fill='red')
        elif lengthList[i] == max(lengthList):

pg. 18
            canvas.itemconfig(barList[i], fill='black')

#Making a window using the Tk widget


window = tk.Tk()
window.title('Sorting Visualizer')
window.geometry('600x450')

#Making a Canvas within the window to display contents


canvas = tk.Canvas(window, width='600', height='400')
canvas.grid(column=0,row=0, columnspan = 50)

#Buttons
insert = tk.Button(window, text='Insertion Sort', command=insertion_sort)
select = tk.Button(window, text='Selection Sort', command=selection_sort)
bubble = tk.Button(window, text='Bubble Sort', command=bubble_sort)
shuf = tk.Button(window, text='Shuffle', command=generate)
insert.grid(column=1,row=1)
select.grid(column=2,row=1)
bubble.grid(column=3,row=1)
shuf.grid(column=0, row=1)

generate()
window.mainloop()

pg. 19
Output:

pg. 20

You might also like