CS162 Lab 7 - Graphical Sort discussion

CS162 Lab 7 - Graphical Sort discussion

- 削除済みユーザ の投稿
返信数: 0

Hi guys, I'll start us off with a tip / thought about the CS162 #7, graphical sort lab many of us may be working on.

I puzzled over how to approach the sort for awhile because my first urge was to just make a sorting method and run it.  But the assignment wants us to display the graphic slowly as it sorts, so a method that just instantly sorts everything won't work.

So here's how I approached it.  I had my array of bar heights, and a timer which 'ticks' every so often.  Every time it ticks, my method takes a variable holding the current array index, sorts the bar with that index, and updates the index to sort the next bar of the array.

So every time that timer happens, 1 bar gets sorted.  It may help to think of it as the timer is the first of 2 nested for loops, the timer works on each of the indexes once, and sorts a single bar by comparing against the rest of the bars.

Anyway, feel free to post your approach or thoughts on this lab.  I usually don't like graphical labs but this was my favorite lab so far, I really enjoyed it.