Deliverables:
To complete this assignment you must --
1.) Write the HTML and JavaScript page described below and demonstrate to
the lab instructor that it operates correctly.
Introduction: The main goal of this assignment is for you to code the BubbleSort algorithms given in class and to see how they operate. In order to give you a good feel for how BubbleSort works we will create the ability to "step" through the algorithm slowly to see the effects of the compare-and-swap behavior.
Swap(x, y): The function that swaps two elements in an array.
Section Pseudocode Comments
Input:
Integer list[12];
Integer x, y;Assume list is a global variable
(declared outside the function).
Use a list of 12 elements.
x and y do not need to be
defined as they are in the
function name Swap(x, y),
Others:
Integer temp;
Local variable, temporary storage.
Initialization:
List given to us
as a global variable.
x and y input as part of the function call.
Computation:
temp = list[x];
list[x] = list[y];
list[y] = temp;
Output:
Nothing to do here.
Bubble(): The function that passes through the array one time.
Section Pseudocode Comments
Input:
Integer list[12];
Same global list is used
everywhere.
Others:
Integer i;
Local variable, loop counter.
Initialization:
List given to us
as a global variable.
Computation:
FOR i = 0 to 10 DO
   IF ( list[i] > list[i+1]) THEN
      swap( i, i+1 );
   ENDIF
ENDDO
Output:
Post()
The Post() function displays the results.
BubbleSort(): The main level program that puts it all togethor.
Section Pseudocode Comments
Input:
Integer list[12];
Same global list is used
everywhere.
Others:
Integer i;
Local variable, loop counter.
Initialization:
List given to us
as a global variable.
Computation:
FOR i = 0 to 12 DO
   Bubble();
ENDDO
Output:
Post()
The Post() function displays the results.