In an homage to the seminal computer animation, "Sorting out Sorting" by Ronald M. Baecker and David Sherman at University of Toronto, presented at SIGGRAPH 1981, this present day retrospective embarked on a man-machine collaboration to revisit the concept with modern LLM technology. To complete this "quick-hack" nod to the original, ChatGPT-4, was employed to illuminate the intricacies of sorting algorithms through a Python demonstration that was built and run for multiple cases in an evening - a much shorter period of time that coding this from scratch, for this author anyway.
In the end, this collaboration focused on four sorting algorithms: quicksort, bubblesort, insertion sort, and selection sort. Each algorithm was animated to showcase its operational nuances and performance implications, dependent on the array size.
The exploration spanned various case studies, from sorting four items to the challenge of a forty-item array. These cases illustrated the performance scalability of each algorithm, reinforcing the importance of algorithm choice based on data size and structure.
The effort culminated in a Python-based animation, refined across 16 shots to aid clarity, accuracy, and pedagogical value. This man-machine collaboration with ChatGPT-4 underscores the synergy between human expertise and artificial intelligence in computer science education.
For those intrigued by the nuances of algorithm efficiency and the visual pedagogy of sorting, this quick project serves as a testament to the enduring relevance of the original "Sorting out Sorting" and the evolutionary journey of computational teaching tools and the technology that drives them.
Results:
Note the number of steps that each sort took for each of the size-item cases:
1) The four-item case:
2) The five-item case:
3) The ten-item case:
4) The twenty item case:
5) The forty item case:
Notice the relatively poor performance of quicksort relative to the other sorts for small numbers of items and the relatively good performance of selection sort.
TLDR;
Parallel attempts were made using ChatGPT-3.5 and Claude3-Opus, but these fell short of expectations, so the author used ChatGPT-4 to execute a brief exploration of sorting algorithms. The conversation that led to acceptable code required16 iterative chat laps outlined for those who are coding with Large Language Models (LLMs) as follows:
- Initial Request: Asked for a Python demo to animate sorting with a comparison of quicksort and bubblesort in Jupyter Notebook using Google Colab.
- Clarification and Correction: Adjustments were made to increase the array size, which caused an IndexError.
- Fix for IndexError: Provided a solution to fix the IndexError related to the array size increase.
- Background Color Adjustment: You requested changing the graph background to your trademark color and further adjustments.
- Sorting Algorithm and Layout Update: Requested adding mergesort to the comparison and faced an execution error.
- Alternative Sorting Algorithm: Suggested using insertion sort as an easier alternative for visualization.
- Visualization Enhancement: Added detailed visualization for tracking the sorting process with colors.
- Error Handling: Addressed an IndexError related to indexing issues in the updated visualization code.
- Additional Sorting Algorithm and Grid Layout: Included a fourth sorting algorithm and updated the layout to a 2x2 grid.
- Visual Tracking Features: Requested marking special elements (pivot, etc.) with specific colors for clarity, this was successful, though quite complex to track.
- Step Annotations Missing: Noted that step annotations were dropped from the visualization.
- Reintroduction of Step Annotations: Added step annotations back into the visualization for clarity.
- Title Color Adjustment: You wanted the titles of the sorting algorithms colored blue.
- Legend Addition: Asked to add a legend explaining the color coding of the elements.
- Legend Visibility Issue: Addressed the issue where the video progress bar covered the legend.
- Conclusion: Expressed satisfaction with the assistance provided.
Python 3 Source: (Run in a Google Colab Jupyter Notebook)
No comments:
Post a Comment