Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

FinalExam Review Spring2006: Reverse the Insert

Questions? Answers? Comments? Comments on Questions or Answers?
(Back to Final Exam Review Spring2006)



Is there an addFirst statement to match the addLast one? That would be great.

Again.. I seem to think that you just need to change your greaterthan/lessthan sign to the opposite of what it is.. but that seems really simple.. I think I might try it in Dr. Java and see.. If I do - I'll get back here.

changing the less than sign to a greater than sign should work on this line:
if (thisEvent.getTime() < comparison.getTime())
if you do that you don't have to worry about changing the addLast statement to addFirst. if the element you are sorting is smaller than all the other ones, it won't be inserted with the for loop and will be put at the end where it's supposed to be. Hope that makes sense. It would be nice to test this code to make sure.

Agreed – Test It while you have the chance! Mark Guzdial



Link to this Page