This Python library provides functions for visualizing various data structures, including linked lists, queue, stack, and more. It utilizes Matplotlib for creating interactive and informative visualizations.
This library was developed for the Data Structures and Algorithms course at King Mongkut's Institute of Technology Ladkrabang (KMITL) to enhance student understanding of these fundamental concepts.
Table of Contents
Data Visualization
Sorting Visualization
Installation
Install using pip
pip install visualdsa
Stack
Context
- A stack is a linear data structure that follows the Last-In, First-Out (LIFO) principle.
- Imagine a stack of plates – you can only add or remove plates from the top of the stack.
Sample stack class
class ArrayStack:
def __init__(self):
self._data = []
def __len__(self):
return len(self._data)
# ... (class methods)
Visualization
import visualdsa as vd
# Sample stack data
my_stack = ArrayStack()
my_stack._data = [3, 2, 1]
# Visualize the stack
vd.showStack(my_stack)
Queue
Context
- A circular queue is a linear data structure that follows the First-In, First-Out (FIFO) principle, like a regular queue, but with a circular arrangement.
- The last element of the queue is logically connected to the first element, creating a circular structure. This efficient use of space by avoiding wasted memory at the beginning of the array.
- There are 2 pointers, front and rear, track the positions of the first and last elements in the queue, respectively.
Sample circular queue class
class ArrayQueue:
def __init__(self):
self._data = [None] * 5 # A list to store the queue elements with capacity of 5
self._front = 0 # The index of the front of the queue
self._rear = 0 # he index of the rear of the queue
def __len__(self):
return len(self._data)
# ... (class methods)
Visualization
import visualdsa as vd
# Sample queue data
my_queue = ArrayQueue()
my_queue._data = [3, 2, 1, None, None]
my_queue._front = 0
my_queue._rear = 2
# Visualize the queue
vd.showQueue(my_queue)
Singly Linked List
Context
- A singly linked list is a linear data structure where each element (node) points to the next element in the sequence.
Sample singly linked list class
class DataNode:
def __init__(self, name, next):
self._name = name # The value stored within the node
self._next = next # A reference to the next node in the list (None if it's the last node)
class SinglyLinkedList():
def __init__(self):
self._count = 0 # The number of nodes in the list
self._head = None # A reference to the first node of the list
# ... (class methods)
Visualization
import visualdsa as vd
# Sample linked list data
my_list = SinglyLinkedList()
my_node1 = DataNode("John", None)
my_node2 = DataNode("Adam", my_node1)
my_list._head = my_node2
my_list._count += 2
# Visualize the linked list
vd.showSinglyLinkedList(my_list)
Bubble Sort
Context
- Compares adjacent elements and swaps them if they are in the wrong order.
- Repeatedly passes through the list until no swaps1 occur in a pass.
Visualization
import visualdsa as vd
arr = [12, 90, 53, 63]
vd.bubbleSort(arr)
Selection Sort
Context
- Finds the minimum element in the unsorted portion of the list and places it at the beginning.
- Repeats this process until the entire list is sorted.
Visualization
import visualdsa as vd
arr = [12, 90, 53, 63]
vd.selectionSort(arr)
Insertion Sort
Context
- Builds the sorted array one element at a time.
- Inserts each element into its correct position within the already sorted portion of the array.
Visualization
import visualdsa as vd
arr = [12, 90, 53, 63]
vd.insertionSort(arr)
Change Log
0.0.1 (21/01/2025)
- First Release
0.0.2 (21/01/2025)
- Debug module
0.0.3 (21/01/2025)
- Clear tester
0.0.4 (22/01/2025)
- Corrected the date in previous changelog
- Updated README.txt with improved documentation, including installation and usage
- Refactored function names to accurately reflect the data structure
showQueue()toshowCircularQueue()showLinkedList()toshowSinglyLinkedList()
0.0.5 (07/02/2025)
- Refactored the
SinglyLinkedListsample class for better code organization and readability. - Added checks for node count mismatches in the linked list visualization and displays a more informative warning message.
- Implemented visualizations for Bubble Sort, Selection Sort, and Insertion Sort, including visual representations of the sorting process.
- Updated the README.md documentation for the new visualization features.
0.0.6 (07/02/2025)
- Updated the README.md table of contents
- Fixed an issue where the example output images in the README.md were outdated or missing.
0.0.7 (11/02/2025)
- Removed test case
Metadata
Release files for visualdsa 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| visualdsa-0.0.7.tar.gz | 7.2 kB | Without provenance | Details |
Release files / visualdsa-0.0.7.tar.gz
| Download URL | visualdsa-0.0.7.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a67b9068e018a85df46df13f31177933c06abe1674e599b2fd433b169176d1e
|
|
BLAKE2b-256 checksum How to use checksums |
ea328f43a3c02684990fbf6076e730ae5f6b149eff5ce8ce615fcd9548794280
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for visualdsa 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.