"Animated" Sorting Algorithms (in Swift)

It’s the last day of NaCreSoMo! I had fun with the last ASCII art program, so I decided to do another one. This one’s a friend to beginning computer science majors everywhere: it animates sorting algorithms.


 *        
 *     *  
 * *   *  
 * *   * *
 * * * * *
-----------

   *      
   *   *  
 * *   *  
 * *   * *
 * * * * *
-----------

     *    
     * *  
   * * *  
   * * * *
 * * * * *
-----------

       *  
     * *  
   * * *  
   * * * *
 * * * * *
-----------

         *
       * *
     * * *
   * * * *
 * * * * *
-----------

(…in a pretty loose sense of the word “animates”. Modified to fit your screen.)

As before, this is written in Swift, and you can check it out yourself (and try different inputs and different sorting algorithms!) on IBM’s Swift Sandbox. (I apologize for the messier code than last time.)

Of course, if you’re on a Mac there’s a much nicer way to view the progress of an algorithm: playgrounds. But if you’re looking for resources beyond the world of Swift, there’s always animations from Wikipedia and, um, dances.

EDIT: And audio! How could I forget audio. Thanks, Facebook recommended links.

…um.


That’s it for NaCreSoMo 2016! I’ll post a retrospective…not tomorrow, probably this weekend. (If I posted it tomorrow you wouldn’t believe me anyway.)

blog comments powered by Disqus