Objective:

Use the Bubble, Insertion, and Selection Workshop applets to help you to understand the insights into the different sorting algorithms covered in Chapter 2. Make sure you can predict what it's going to happen.

At the end of this lab, you need to submit a word document including some text answers and screenshots of your lab result. The way to get the screen shots is to press Key "Print Screen" from your keyboard to get the image of the whole screen, then use Start->All Programs->Accessories->Paint, click Edit->Paint to get the image, use text to add your own name (to replace Qi Zhu), then cut and paste the part of image you want into your homework file such as .doc).

1: Operations on BubbleSort.html

To execute an applet in Internet Explorer, perform the following steps.

(1.) Click Start > Windows System -> Command Prompt

(2.) Use command "cd" to move into the directory where you run the applet, such as cd C:COSC3331\Chap03\Bubble

(3.) Use the command "appletviewer BubbleSort.html", see Figure 1.

Fig. 1 Initial State for 10 Bars of Bubble Sort see image.

(4.) Click Run to execute the bubble sorting algorithm, we have Figure 2 after it stops. Q1: What are the meanings of the blue arrow and the red arrow, corresponding to the bubble algorithm shown on page 86? Q2: After it stops, what are the numbers of swaps and comparisons?(Your answers may be different with mine because of the different initial values)

Fig. 2 Sorted Results for 10 Bars of Bubble Sort see image.

(5.) Click Size to toggle it to 100 bars, then press Run to execute the bubble sorting algorithm, we have Figure 3 after it stops. Q3: After it stops, what are the numbers of swaps and comparisons?

Fig. 3 Sorted Results for 100 Bars of Bubble Sort see image.

(6.) If you want to trace the steps, you could use Draw to stop the running process, and then click Step to execute one step of sorting process.

2: Operations on InsertSort.html

(1.) Under command prompt, change the directory by typing "cd C:\COSC3331\Chap03Insertion".

(2.) Run "appletviewer InsertSort.html", see Figure 4.

Fig. 4 Initial State for 10 Bars of Insertion Sort see image.

(3.) Click Run to execute the insertion sorting algorithm, we have Figure 5 after it stops. Q4: What are meanings of the blue arrow, the red arrow, and the purple arrow, corresponding to the insertion sort algorithm shown on page 99? Q5: After it stops, what are the numbers of copies and comparisons?(Your answers may be different with mine because of the different initial values)

Fig. 5 Sorted Results for 10 Bars of Insertion Sort see image.

(4.) Click Size to toggle it to 100 bars, then press Run to execute the insertion sorting algorithm, we have Figure 6 after it stops. Q6: after it stops, what are the numbers of copies and comparisons?

Fig. 6 Sorted Results for 100 Bars of Insertion Sort see image.

(5.) If you want to trace the steps, you could use Draw to stop the running process, and then click Step to execute one step of sorting process.

3: Operations on SelectSort.html

(1.) Under command prompt, change the directory by typing "cd C:\COSC3331\Chap03Selection". And run appletviewer SelectSort.html, see Figure 7.

Fig. 7 Initial State for 10 Bars of Selection Sort see image.

(2.) Click Run to execute the selection sorting algorithm, we have Figure 8 after it stops. Q7: What are meanings of the blue arrow, the red arrow, and the purple arrow, corresponding to the selection sort algorithm shown on page 93? Q8: After it stops, what are the numbers of swaps and comparisons?(Your answers may be different with mine because of the different initial values)

Fig. 8 Sorted Results for 10 Bars of Selection Sort see image.

(3.) Click Size to toggle it to 100 bars, then press Run to execute the selection sorting algorithm, we have Figure 9 after it stops. Q9: after it stops, what are the numbers of swaps and comparisons?

Fig. 9 Sorted Results for 100 Bars of Selection Sort see image.

(4.) If you want to trace the steps, you could use Draw to stop the running process, and then click Step to execute one step of sorting process.

4: Results Comparison

Q10: List a table to sum up the TOTAL computation number to compare your results, for both 10 and 100 bars, which algorithm is the fastest, and which one is the slowest? Assume one swap is equal to 3 copies and one copy is equal to one comparison, so the total computation number can be summed up.

Part I: Answer the questions:

Q1: What are the meanings of the blue arrow and the red arrow, corresponding to the bubble algorithm shown on page 86?

Q2: After it stops, what are the numbers of swaps and comparisons for 10 bars?

Q3: After it stops, what are the numbers of swaps and comparisons for 100 bars?

Q4: What are meanings of the blue arrow, the red arrow, and the purple arrow, corresponding to the insertion sort algorithm shown on page 99?

Q5: After it stops, what are the numbers of copies and comparisons for 10 bars?

Q6: After it stops, what are the numbers of copies and comparisons for 100 bars?

Q7: What are meanings of the blue arrow, the red arrow, and the purple arrow, corresponding to the selection sort algorithm shown on page 93?

Q8: After it stops, what are the numbers of swaps and comparisons for 10 bars?

Q9: After it stops, what are the numbers of swaps and comparisons for 100 bars?

Q10: After summing up the total computation number, compare your results in a table for both 10 and 100 bars, which algorithm is the fastest, and which one is the slowest? Assume one swap is equal to 3 copies and one copy is equal to one comparison.

Part II: Screen shots

Submit the screenshots for Figure 1 to Figure 9 (totally 9 figures) through Blackboard. (Don't forget to include your name in the program). (At the end of this lab, you need to submit a word document including some screenshots of your lab result. The way to get the screen shots is to press Key "Print Screen" from your keyboard to get the image of the whole screen, then use Start->All Programs- >Accessories->Paint, click Edit->Paint to get the image, use text to add your own name (to replace Qi Zhu), then cut and paste the part of image you want into your homework file such as .doc).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.