Problem

Graphical demonstrations of various sorting algorithms are instructive, as they provide in...

Graphical demonstrations of various sorting algorithms are instructive, as they provide insight into how an algorithm behaves. Consider a collection of vertical lines of varying lengths, such as the ones in Figure 3. Create a sorting demonstration that sorts the lines by length, as shown in Figure 3. You should draw the configuration of lines after every swap or move that a given sorting algorithm makes. If you delay execution very briefly after each redraw, the result will be an animation of the sort.

You could begin by drawing 256 lines, each one pixel wide but of different lengths—and perhaps different colors—arranged from shortest to longest so that they appear as a triangle. The user then should exercise an option to scramble the lines. At a user signal, your sorting algorithm should sort the lines.

You can provide individual demonstrations, perhaps as applets, for each sort algorithm. Or you can include all the algorithms in one program that asks the user to choose an algorithm. Each sort should start with the same scrambled lines so the user can compare methods. You might also choose a sort algorithm at random and see whether the user can guess which one it is.

FIGURE 3 An animated sorting demonstration that sorts vertical lines (a) before its execution; (b) after its execution

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT