Sorting Visualization
By
Naveen Lakheera
(B.Tech 2nd Year, Enrollment No.: 12023002026052 )
Under the Supervision of
Dipta Mukherjee
Dept. of Computer Science & Engineering
University of Engineering & Management, Jaipur
Dept. of CSE, University of Engineering &
Management Jaipur
Outlines
Introduction
Literature Review
Objectives
Proposed Model
Experimental Setup
Result Analysis
Conclusion & Future Scope
Reference
Acknowledgement
Dept. of CSE, University of Engineering &
Management Jaipur
Introduction
What is Sorting?
• Sorting is the process of arranging data in a specific order (e.g.,
ascending or descending).
• Core concept in data organization, database operations, and
algorithm optimization.
Why Visualization?
• Aids in understanding complex algorithmic steps.
• Simplifies comparison of algorithm performance.
• Goal:
• Demonstrate sorting visually to bridge theoretical and practical
understanding.
Jaipur National University, Jaipur
Literature Review
Existing Solutions:
1. Online tools like VisuAlgo, Sorting Tutorials.
2. Limitation: Lack of customization, real-time execution control.
Proposed Solution:
1. Python-based visualization with real-time bar chart updates.
2. Focus on user interaction, learning, and computational insights.
3. Impact: Combines academic understanding with practical
learning.
Dept. of CSE, University of Engineering &
Management Jaipur
Objectives
Educational Goals:
Simplify understanding of sorting techniques.
Provide hands-on experience with algorithmic workflows.
Research Goals:
Compare and contrast sorting algorithms on performance.
Evaluate efficiency in terms of time complexity.
Technical Goals:
Develop an interactive, user-friendly visualization tool.
Dept. of CSE, University of Engineering &
Management Jaipur
Proposed Model
Architecture:
1. Input: User-provided or random-generated dataset.
2. Processing: Selection of one of five sorting algorithms.
3. Output: Real-time visualization with color-coded steps.
Algorithms Implemented:
1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4. Merge Sort
5. Quick Sort
Key Features:
1. Dynamic visualization for step-by-step understanding.
2. Clear time complexity and performance display.
Dept. of CSE, University of Engineering &
Management Jaipur
Experimental Set-up
Software Environment:
Language: Python
Libraries: matplotlib, random, time
User Inputs:
Dataset: User-defined or randomly generated.
Algorithm Selection: Interactive choice menu.
Data Representation:
Bars represent data values.
Height of bars corresponds to data magnitude.
System Design:
Color-Coded Visualization:
Blue: Unsorted
Red: Comparison in progress
Yellow: Pivot/Minimum element (specific to algorithm)
Green: Sorted Dept. of CSE, University of Engineering &
Management Jaipur
Result: Example
Example Input
User Input Data: 5, 2, 9, 1, 5, 6
Algorithm Selected: Bubble Sort
Visualization Process
Initial State:
Bars: Blue
Data: [5, 2, 9, 1, 5, 6]
Step 1:
Compare 5 and 2 → Swap → Bars for 5 and 2 turn Red.
Data: [2, 5, 9, 1, 5, 6]
Step 2:
Compare 9 and 1 → Swap → Bars turn Red.
Data: [2, 5, 1, 9, 5, 6]
Jaipur National University, Jaipur
Result: Example
Final State:
1. All bars turn Green → Sorted Data: [1, 2, 5, 5, 6, 9]
2. Execution Time
3. Sorting completed in 0.35 seconds.
Time Complexity
1. Bubble Sort: O(n^2)
Visual Representation
1. Include a screenshot of the bar chart showing the visualization at
different stages (e.g., initial, intermediate, final).
Dept. of CSE, University of Engineering &
Management Jaipur
Result Analysis
Visualization Highlights:
1. Bubble Sort: Repeated comparison and swaps.
2. Selection Sort: Iterative selection of the smallest element.
3. Insertion Sort: Incremental sorting by shifting elements.
4. Merge Sort: Divide-and-conquer approach.
5. Quick Sort: Partitioning based on pivot element.
Dept. of CSE, University of Engineering &
Management Jaipur
Result Analysis
Performance Metrics:
Time Complexity:
1. Bubble/Selection/Insertion: O(n^2)
2. Merge: O(nlogn)
3. Quick: WorstO(n^2),Avg O(nlogn)
Execution Time: Displayed dynamically during the process.
Key Observations:
1. Visual patterns show inherent differences in algorithm behavior.
2. Merge and Quick Sort outperform for larger datasets.
Dept. of CSE, University of Engineering &
Management Jaipur
Limitation
Algorithm Scope
1. Limited to five sorting algorithms (Bubble, Selection, Insertion,
Merge, Quick).
2. Advanced algorithms like Heap Sort, Radix Sort, or external sorting
are not included.
Dataset Size
1. Visualization performance decreases for large datasets due to the real-
time rendering of the bar chart.
2. Unsuitable for datasets with thousands of elements.
Visualization Speed
1. Speed of visualization is tied to computational resources and the
pause duration (plt.pause()).
2. Users may find it slow for large arrays or complex algorithms
Dept. of CSE, University of Engineering &
Management Jaipur
Limitation
Limited User Interaction
1. The user can only choose algorithms and provide data but cannot
control intermediate steps or pause/resume the process.
No Parallel Algorithm Support
1. Does not demonstrate parallelized sorting methods, which are
critical for modern applications.
Graphical Interface
1. Visualization is confined to command-line input and Matplotlib
output .
2. No advanced GUI for more intuitive interaction.
Dept. of CSE, University of Engineering &
Management Jaipur
Limitation
Time Complexity Representation
Time complexity displayed is theoretical; actual runtime is influenced
by hardware and data structure overhead.
Learning Focus
The project is educational and not optimized for real-world large-scale
applications or competitive programming.
Dept. of CSE, University of Engineering &
Management Jaipur
Conclusions & Future Scope
Conclusion:
1. Sorting visualization enhances learning by showing algorithm
dynamics.
2. Performance metrics validate theoretical time complexity.
Future Enhancements:
1. Add algorithms: Heap Sort, Radix Sort.
2. Include adaptive features for varying dataset sizes.
3. Implement 3D visualization for more immersive insights.
4. Optimize for larger data sets and parallel execution.
Dept. of CSE, University of Engineering &
Management Jaipur
References
Primary Resources:
1. Python Official Documentation
2. Matplotlib Documentation
Supplementary Texts:
1. "Introduction to Algorithms" by Cormen et al.
2. Research papers on sorting algorithm optimizations.
Dept. of CSE, University of Engineering &
Management Jaipur
Acknowledgement
Special Thanks To:
Academic mentors(Dipta Mukherjee) for guidance.
Online communities for resources and ideas.
Team members 1 .
Name - Prashant Kumawat
Enrollment-22024002026001
Team member 2.
Name - Aryan Jangid
Enrollment-12023002001086
Dept. of CSE, University of Engineering &
Management Jaipur
Dept. of CSE, University of Engineering &
Management Jaipur