Sample Run

assignment description

This file shows the expected output of the ShakerSort program after the revisions have been completed.

Note that the last array sorted has been randomly generated, and so your output will differ from what's shown in that part below.

For the first two parts (the nearly sorted array and the completely sorted array), your output should match mine exactly.

Shaker Sort =========== This program demonstrates an improvement to bubble sort. A mostly sorted list: 3 4 5 1 2 6 7 8 9 10 ...press enter... Array after bubbling up: 3 4 1 2 5 6 7 8 9 10 Unsorted part 3 4 1 2 ... ... ... ... ... ... ...press enter... Array after bubbling down: 1 3 4 2 5 6 7 8 9 10 Unsorted part ... 3 4 2 ... ... ... ... ... ... ...press enter... Array after bubbling up: 1 3 2 4 5 6 7 8 9 10 Unsorted part ... 3 2 ... ... ... ... ... ... ... ...press enter... Array after bubbling down: 1 2 3 4 5 6 7 8 9 10 Unsorted part ... ... 3 ... ... ... ... ... ... ... ...press enter... The sorted array: 1 2 3 4 5 6 7 8 9 10 ...press enter... An entirely sorted array: 1 2 3 4 5 6 7 8 9 10 ...press enter... Array after bubbling up: 1 2 3 4 5 6 7 8 9 10 Unsorted part ... ... ... ... ... ... ... ... ... ... ...press enter... Array after bubbling down: 1 2 3 4 5 6 7 8 9 10 Unsorted part ... ... ... ... ... ... ... ... ... ... ...press enter... The sorted array: 1 2 3 4 5 6 7 8 9 10 ...press enter... Now to try a random list. Enter a trace level: 0 - no tracing 1 - outer loop only 2 - inner loop as well Trace level: 1 963 821 197 857 861 548 890 940 545 697 ...press enter... Array after bubbling up: 821 197 857 861 548 890 940 545 697 963 Unsorted part 821 197 857 861 548 890 940 545 697 ... ...press enter... Array after bubbling down: 197 821 545 857 861 548 890 940 697 963 Unsorted part ... 821 545 857 861 548 890 940 697 ... ...press enter... Array after bubbling up: 197 545 821 857 548 861 890 697 940 963 Unsorted part ... 545 821 857 548 861 890 697 ... ... ...press enter... Array after bubbling down: 197 545 548 821 857 697 861 890 940 963 Unsorted part ... ... ... 821 857 697 861 890 ... ... ...press enter... Array after bubbling up: 197 545 548 821 697 857 861 890 940 963 Unsorted part ... ... ... 821 697 ... ... ... ... ... ...press enter... Array after bubbling down: 197 545 548 697 821 857 861 890 940 963 Unsorted part ... ... ... ... 821 ... ... ... ... ... ...press enter... Array now sorted 197 545 548 697 821 857 861 890 940 963 ...press enter...

Return to Outline page / assignment description