7.11. Discussion QuestionsΒΆ

  1. Generate a random list of integers. Show how this list is sorted by the following algorithms:

    • bubble sort

    • selection sort

    • insertion sort

    • shell sort (you decide on the increments)

    • merge sort

    • quick sort (you decide on the pivot value)

  2. Consider the following list of integers: [1,2,3,4,5,6,7,8,9,10]. Show how this list is sorted by the following algorithms:

    • bubble sort

    • selection sort

    • insertion sort

    • shell sort (you decide on the increments)

    • merge sort

    • quick sort (you decide on the pivot value)

  3. Consider the following list of integers: [10,9,8,7,6,5,4,3,2,1]. Show how this list is sorted by the following algorithms:

    • bubble sort

    • selection sort

    • insertion sort

    • shell sort (you decide on the increments)

    • merge sort

    • quick sort (you decide on the pivot value)

  4. Consider the list of characters: ['P','Y','T','H','O','N']. Show how this list is sorted using the following algorithms:

    • bubble sort

    • selection sort

    • insertion sort

    • shell sort (you decide on the increments)

    • merge sort

    • quick sort (you decide on the pivot value)

  5. Devise alternative strategies for choosing the pivot value in quick sort. For example, pick the middle item. Re-implement the algorithm and then execute it on random data sets. Under what criteria does your new strategy perform better or worse than the strategy from this chapter?

You have attempted of activities on this page
Next Section - 7.12. Programming Exercises