Visualizing Sorting Algorithms DAA Mini Project (1)
Visualizing Sorting Algorithms DAA Mini Project (1)
A PROJECT REPORT
Submitted by
ABHIRAJ ARORA(22BCS14763)
DILBAG YADAV(22BCS15574)
BACHELOR OF ENGINEERING
IN
Chandigarh University
October, 2024
BONAFIDE CERTIFICATE
Certified that this project report “Visualizing Sorting Algorithms” is the bonafide
work of “ABHIRAJ ARORA(22BCS14763), DILBAG YADAV(22BCS15574)”
who carried out the project work under my/our supervision.
SIGNATURE SIGNATURE
Identification of Problem.................................................................................................. 1
2.1. Goals/Objectives
• Real-time Feedback: One of the main goals of the sorting process is to provide
real- time feedback. In order to empower users to make wise decisions, the visualizer
seeks to provide them with instantaneous insights on the effects of their interactions.
• Practical Application: The visualizer ought to function as a useful learning aid in
addition to imparting theoretical knowledge. Users ought to be able to try out various
situations and obtain practical experience with data sorting.
The current state of sorting algorithm research is focused on the development of new
algorithms and the optimization of existing ones to handle increasingly complex and
large-scale datasets more efficiently. With the exponential growth of data across
various fields, sorting large datasets has become critical, especially in fields like big
data analytics, artificial intelligence, and scientific computing. Researchers are
exploring innovative approaches to enhance both speed and scalability, with
significant attention on the following areas:
Distributed and Parallel Sorting: With the rise of multicore processors and
distributed computing systems, parallel sorting algorithms have gained immense
importance. These methods allow sorting tasks to be split across multiple processors,
significantly speeding up the process. Algorithms like parallel Quick Sort and
parallel Merge Sort leverage concurrent processing, where data is divided and
processed simultaneously, making them ideal for systems where high performance
and speed are paramount. Distributed sorting methods are also essential in cloud
computing and big data platforms where datasets are distributed across multiple
nodes.
External Sorting: In cases where datasets exceed the capacity of a computer’s main
memory, external sorting algorithms become indispensable. These algorithms, such
as Multiway Merge Sort, are designed to manage large-scale datasets by minimizing
the number of expensive disk I/O operations. They ensure that the majority of data
processing happens in memory, while carefully accessing external storage only when
necessary. This is critical in scenarios where datasets are too large to fit into the
system’s RAM, such as in large database management systems and big data
platforms.
# Buttons def
start_btn():
stop_flag = False
if sorting_algorithm.get() == 'Bubble Sort':
sorting_alg.bubble_sort(dataset, draw_data, animation_speed.get(), stop_flag)
update_header_labels(sorting_alg.get_comparisons_count(), 'O(n^2)')
elif sorting_algorithm.get() == 'Quick Sort':
sorting_alg.quick_sort(dataset, 0, len(dataset) - 1, draw_data,
animation_speed.get()) draw_data(dataset, ['green' for i in
range(len(dataset))])
update_header_labels(sorting_alg.get_comparisons_count(), 'O(n log n)')
generateBtn.config(state=NORMAL)
startBtn.config(state=NORMAL) stopBtn.config(state=DISABLED)
resetBtn.config(state=NORMAL)
def stop_btn():
global stop_flag
stop_flag = True
def reset_btn(): global dataset dataset = []
comparison_label.config(text="")
algorithm_complexity_label.config(text="")
draw_data(dataset, [])
# A utility function to draw the dataset. It can draw the dataset in 3 different ways:
# 1. Bar
# 2. Scatter # 3. Stem def
draw_data(data_set, clr):
if graph_type.get() == 'Bar':
cv.delete('all') cv_height = 380
cv_width = 700 x_width = cv_width /
(len(data_set) + 1) offset = 30
space_between = 5 data = [i /
max(data_set) for i in data_set] for i, h in
enumerate(data):
for i, h in enumerate(data):
x = i * x_width + offset y
= cv_height - h * 320
for i, h in enumerate(data):
x = i * x_width + offset y
= cv_height - h * 320
cv.create_oval(x - 2, y - 2, x + 2, y + 2, fill=clr[i])
cv.create_text(x + 5, y - 5, anchor=SW, text=str(data_set[i]))
root.update_idletasks()
# A utility function to generate a dataset with random numbers
# this function is called in case the user did not enter any values through entry def
generate_dataset():
global dataset min_val =
int(dataset_min_value.get()) max_val =
int(dataset_max_value.get()) data_size
= int(dataset_size.get())
dataset = [] for i in
range(data_size):
dataset.append(random.randrange(min_val, max_val + 1))
# draw data draw_data(dataset, ['#FF597B' for i in
range(len(dataset))]) # A utility function to show the
comparisons count and time
Output
RESULTS ANALYSIS AND VALIDATION
Conclusion
An excellent instructional tool that offers a natural way to comprehend sorting
algorithms is the Sorting Algorithm Visualizer. To improve the learning process, it
provides interactive controls, acoustic effects, and real- time feedback. By seeing the
algorithms in operation, users can obtain useful insights into how they
operate.Sorting algorithm visualizations help one grasp how they work intuitively.
Comprehending can be further improved with tools like step-by-step simulations and
animated images. Here are some tools and resources that you can use: