Self-Review Questions

  1. Use selection sort to sort the following numbers in ascending order: 3 5 1 6 9 4 2

  2. Use insertion sort to sort the following numbers in ascending order: 3 5 1 6 9 4 2

  3. What is the worst-case runtime complexity of insertion sort?

  4. What is the best-case runtime complexity of insertion sort?

  5. What is the worst-case runtime complexity of selection sort?

  6. What is the worst-case runtime complexity of mergesort?

  7. What is the best-case runtime complexity of mergesort?

  8. What is the worst-case runtime complexity of bucket sort?

  9. Given a million objects in memory (assume we have no memory constraints) all of type HighSchoolStudent:
    public class HighSchoolStudent
    {
       private String name;
       private int numberOfYearsOld;
    }
    
    What sorting algorithm would you use, and why, to sort these objects by the second field numberOfYearsOld?

  10. Why would one ever choose insertion sort over mergesort?

  11. Why would one ever choose the bubble sort over the mergesort?

  12. True or False. Sorting 6 elements with a comparison sort requires at least 10 comparisons.