• Post Reply Bookmark Topic Watch Topic
  • New Topic

Selection sort of bar graph using timer  RSS feed

 
matt Seidlitz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
d
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Timer are you using? java.util or javax.swing? The two are very different.
How long are you allowing between "ticks"? Are you allowing long enough for the display to be repainted?
Do you have a method which goes one step in the sorting process? You would have to set up the array, and probably the two indices as fields, and make a sortOneStep method, which takes one step in the sorting process. Remember that selection sort runs in quadratic time, so the number of iterations through the entire array is n and the total number of steps is something like (n^2 + n) / 2.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!