Sorting algorithms visualized using the Blender Python API.
Running one of the scripts in this project generates primitive meshes in Blender, wich are animated to visualize various sorting algorithms.
Keyframes are incrementaly inserted according to the current position of the element in the array during the sorting.
The four folders (sort_circle, sort_color, sort_combined, sort_scale) contain four different types of visualization.
| Type | Sorting Criteria | Representation of Index | Extras |
|---|---|---|---|
| sort_circle | hsv of material | rotation of cuboid | hsv = 360° |
| sort_color | red + green of material | location of plane | custom color gradient |
| sort_combined | red + green of material | location of plane | multiple 2d arrays arranged into a cube |
| sort_scale | scale of cubiod | location of cuboid | array access and comparison counter |
These visualizations don't show the efficiency of the algorithms.
They only visualize movement of the elements within the array.
But the array access and comparison counters are indicators of the time complexity of the algorithms.
For more information about the time complexity, you can take a look at the Big O Table.
Below I compiled a list of features that could be implemented in the future.
Contributions to this project with either ideas from the list or your own are welcome.
| combined_sort_cube.py |
|---|
![]() |
Bubble sort is one of the most straightforward sorting algorithms, it makes multiple passes through a list.
In essence, each item “bubbles” up to the location where it belongs.
| bubble_sort_scale.py | bubble_sort_color.py | bubble_sort_circle.py |
|---|---|---|
![]() |
![]() |
![]() |
Like bubble sort, the insertion sort algorithm is straightforward to implement and understand.
It splits the given array into sorted and unsorted parts, then the values from the unsorted parts are picked and placed at the correct position in the sorted part.
| insertion_sort_scale.py | insertion_sort_color.py |
|---|---|
![]() |
![]() |
The algorithm maintains two subarrays in a given array.
In every iteration of selection sort, the minimum element (considering ascending order) from the unsorted subarray is picked and moved to the sorted subarray.
| selection_sort_scale.py | selection_sort_color.py | selection_sort_circle.py |
|---|---|---|
![]() |
![]() |
![]() |
Based on the binary heap data structure, heap sort is mainly considered as a comparison-based sorting algorithm.
In this sorting technique, at first, the minimum element is found out and then the minimum element gets placed at its right position at the beginning of the array.
For the rest of the elements, the same process gets repeated.
So, we can say that heap sort is quite similar to the selection sort technique.
Heap sort basically recursively performs two main operations:
| heap_sort_scale.py | heap_sort_color.py |
|---|---|
![]() |
![]() |
The shell sort algorithm extends the insertion sort algorithm and is very efficient in sorting widely unsorted arrays.
The array is divided into sub-arrays and then insertion sort is applied.
The algorithm is:
This sorting technique works by sorting elements in pairs, far away from each other and subsequently reduces their gap.
The gap is known as the interval. We can calculate this gap/interval with the help of Knuth’s formula.
| shell_sort_scale.py | shell_sort_color.py |
|---|---|
![]() |
![]() |
Merge sort uses the divide and conquer approach to sort the elements.
It is one of the most popular and efficient sorting algorithms.
The sub-lists are divided again and again into halves until the list cannot be divided further.
Then we combine the pair of one element lists into two-element lists, sorting them in the process.
The sorted two-element pairs is merged into the four-element lists, and so on until we get the sorted list.
| merge_sort_scale.py | merge_sort_color.py | merge_sort_circle.py |
|---|---|---|
![]() |
![]() |
![]() |
Like Merge Sort, Quick Sort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. There are many different versions of Quick Sort that pick pivot in different ways.
The key process in quickSort is partition(). Target of partitions is, given an array and an element x of array as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x.
All this should be done in linear time.
| quick_sort_scale.py | quick_sort_color.py | quick_sort_circle.py |
|---|---|---|
![]() |
![]() |
![]() |
Big O notation is the language we use for talking about how long an algorithm takes to run.
It's how we compare the efficiency of different approaches to a problem.
With Big O notation we express the runtime in terms of **how quickly it grows relative to the input, as the input gets arbitrarily larg
$ claude mcp add Sorting-Algorithms-Blender \
-- python -m otcore.mcp_server <graph>