Animated Selection Sort Project

SS1 SS2

After learning the basics of processing.js, we move on to algorithms, particularly for sorting. We then implemented Selection Sort for sorting cheesesticks (Basically a bunch of rectangles) in ascending order. We had to use ‘for loops’ to check each of the cheesesticks, and then two int functions, ‘i’ and ‘j’ and a temporary variably to hold the values of ‘i’ and ‘j’ when they awe swapped.

After getting the sorting function to work in ascending order, our next task was to animate the cheesesticks and show the sorting. Using ‘if statements’ in the draw function, we were able to implement the animation effects, and visually depict the Selection Sort Algorithm.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s