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

FinalExam Review Sp2005: Explain the Sort

Post Answers, Questions, Comments, etc. here.


A. Why does the position value start at 1? Why not 0?
Because EventQueues works backwards. So when we compare events we are actually moving towards 0 instead of away from it. I am still kind of confused about this.
Nope
B. What's going on in the loop where Position A is?
The loop is moving the elements up one.
Up? What direction is up?
C. At Position B, what can we say about the values from 0 to position in the list?
There are only elements from 0 to 1 to position?
No, there are elements in all positions in the list.

A)
It starts at 1 because it assumes that 0 is in the correct place. Which means it takes 1 then compares backwards to 0, if the number is less than/or greater depending on the type of sort the function is, then 0 will be replaced with 1.

B) At position A it is comparing the two numbers for which is greater than the other, if it is not in the correct place then it's moved -1 down the list. Once this is true or it runs out of space the loop will break.

c) we can assume that all the numbers are in the correct order, whether that be decending or acending. It must be noted that these numbers are not static because as the list is sorted there may more numbers that need to be placed between 0 and position.

i'm endorse the latter explaination and i am looking forward to comments.

"I'm endorse"? "Endorse" as an adjective? :-) Mark Guzdial


you're killing me guzdial. :-)

i believe the last answer above is correct. if there was anything wrong i bet you'd have posted.