Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you have the following list: [6, 2, 8, 7, 3, 9, 5, 1, 4] For this questi

ID: 3698434 • Letter: S

Question

Suppose you have the following list:

[6, 2, 8, 7, 3, 9, 5, 1, 4]

For this question, manually illustrate how this list is sorted using the bubble sort algorithm. Show each comparison [2 marks] and each swap [3 marks], although you can summarize repeated comparisons or swaps if you can do so in a manner that is clear to the TAs.

You may use any reasonable way to visualize the steps (for example, bolding the numbers about to be swapped or numbers being compared and writing a note about what happens to them or circling items and drawing arrows, etc). It is recommended that you use either MS Word or Powerpoint to illustrate each step (tables with 1 row work well), however you may use any program you feel is appropriate. Ensure that your final product is saved as a .pdf file. If you wish to draw by hand, that's fine, but ensure that the image is clear and legible when included in your pdf. Illegible drawing/handwriting may result in loss of marks.

Explanation / Answer

In each iteration, the underlined numbers are swapped. The numbers which are bubbled up are shown in bold.

Iteration 1

6       2       8       7       3       9       5       1       4

2       6       8       7       3       9       5       1       4

2       6       7       8       3       9       5       1       4

2       6       7       3       8       9       5       1       4

2       6       7       3       8       5       9       1       4

2       6       7       3       8       5       1       9       4

2       6       7       3       8       5       1       4       9

Iteration 2

2       6       7       3       8       5       1       4       9

2       6       3       7       8       5       1       4       9

2       6       3       7       5       8       1       4       9

2       6       3       7       5       1       8       4       9

2       6       3       7       5       1       4       8       9

Iteration 3

2       6       3       7       5       1       4       8       9

2       3       6       7       5       1       4       8       9

2       3       6       5       7       1       4       8       9

2       3       6       5       1       7       4       8       9

2       3       6       5       1       4       7       8       9

Iteration 4

2       3       6       5       1       4       7       8       9

2       3       5       6       1       4       7       8       9

2       3       5       1       6       4       7       8       9

2       3       5       1       4       6       7       8       9

Iteration 5

2       3       5       1       4       6       7       8       9

2       3       1       5       4       6       7       8       9

2       3       1       4       5       6       7       8       9

Iteration 6

2       3       1       4       5       6       7       8       9

2       1       3       4       5       6       7       8       9

Iteration 7

2       1       3       4       5       6       7       8       9

1       2       3       4       5       6       7       8       9

Iteration 8

1       2       3       4       5       6       7       8       9

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote