Skip to content

MartoNievas/Sorting-Visualizer-In-Smalltalk-Cuis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sorting Visualizer

A sorting algorithm visualizer built in Cuis Smalltalk using Morphic.

What it does

Shows a real-time animation of several sorting algorithms working on a collection of numbers, drawn as vertical bars. Bars currently being compared or swapped are highlighted in red; the rest stay blue.

Structure

  • SortingVisualizerWindow: the main window that holds the visualizer. Subclass of SystemWindow.
  • SortingVisualizerMorph: handles drawing and animation logic. Subclass of BoxMorph.

Usage

Open a Workspace in Cuis and run:

SortingVisualizerWindow withBubbleSort: (1 to: 50) asOrderedCollection shuffled.
SortingVisualizerWindow withSelectionSort: (1 to: 50) asOrderedCollection shuffled.
SortingVisualizerWindow withInsertionSort: (1 to: 50) asOrderedCollection shuffled.
SortingVisualizerWindow withQuickSort: (1 to: 50) asOrderedCollection shuffled.
SortingVisualizerWindow withMergeSort: (1 to: 50) asOrderedCollection shuffled.
SortingVisualizerWindow withBogoSort: (1 to: 8) asOrderedCollection shuffled.

You can change the collection size or use any collection of numbers. Keep the collection small for Bogo Sort, it can take a very long time to finish on anything bigger than a handful of elements.

Algorithms

  • Bubble Sort
  • Selection Sort
  • Insertion Sort
  • Quick Sort
  • Merge Sort
  • Bogo Sort

Technical details

  • Sorting runs on a separate process (fork) so it doesn't block the UI.
  • step / stepTime keep the redraw loop running without needing user input.
  • redrawNeeded tells Morphic to call drawOn: on the next cycle.
  • Processor yield hands off control between swaps so the UI can redraw.

Requirements

  • Cuis Smalltalk 6.x or later

References

Daniel Hirsch's video

Salar's video on C++ OOP

About

Real-time sorting algorithm visualizer built in Cuis Smalltalk with Morphic

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors