Insertion Sort (w/ Shuffle)
Pre-work
- In Barron's AP Computer Science A, read about Insertion Sort on p. 325.
- Optional: Read about insertion sort in another text book that will be made available to you in class.
- Explore https://www.tutorialspoint.com/compile_java_online.php.
- Study this Java implementation of insertion sort.
- Read the multiple choice questions on sorting and searching on pp. 331-345 of Barron's AP Computer Science A. Attempt to answer the questions that are related to insertion sort and then check your answer(s) using the answers provided on pp. 346-350.
Questions
- [1 point] Which questions in Barron's AP Computer Science A (pp. 331-345) involve or are related to insertion sort? List the question numbers only.
- [2 points] What determines whether this Java implementation of insertion sort sorts elements in ascending or descending order?
Create Activity
- [3 points] Create a multiple choice question about insertion sort. You question should include five choices (a - e) for the answer and only one correct answer. Your question may be inspired by a question from Barron's AP Computer Science A but must be substantially different, i.e. you should feel confident that no one would ever accuse you of plagiarizing the question.
- [15 points] Study DoTheShuffle. In the body of the email that you submit to the graders or in a single attached file, submit a single Java program that satisfies the following requirements:
- [5 points] Place all of the classes need to compile and run DoTheShuffle in a single file and verify that the code compiles and runs. If code that you submit compiles, runs, and produces output, then you will earn the points for this portion of the activity.
- [5 points] Modify the implementation of DoTheShuffle so that it outputs the original sequence, the sequence sorted in ascending order, the sequence sorted in descending order, and the sequence after shuffling. The output of the modified program should contain one more line of output than the original version of the program.
- [5 points] Modify the implementation of the maneuver method of LazyStudentShuffler so that it actually shuffles the values of the array argument called seq. Make sure that your program runs as expected for input sequences comprised of zero elements (1 point), one element (1 point), two elements (1 point), and more than two elements (2 points).