- Implement the selection sort algorithm for the array and indicate the results in parts A and D.
7 3 0 8 1
[0] [1] [2] [3] [4]
- How many passes are required for the sort?_____
- 4
- 5
- 6
- 3
- After pass 1, list the elements in their given order____
- In pass 2 which element is selected?______. Which 2 array items are exchanged?________and_______
- After pass 3 the elements in their given order___________
- How many comparisions are required to order an array of 5 elements using the selection sort?
- 10
- 15
- 20
- 30
- For a 5 element list the number of comparisions in a selection sort becomes___ if the list is already sorted?
- 0
- 10
- 1
- 20
- For a 5 element list the number of comparisions in a selection sort becomes___ if the list is already sorted in reverse order?
- 0
- 10
- 1
- 20
- What is the maximum number of exchanges required to order an array of 5 elements using the selection sort?_____
- What is the average case computational complexity of the selection sort?
- O(n log2n)
- O(n2)
- O(n)
- O(n3)
- There is no difference between the best and worst case effeciency for the selection sort?
- true
- false
- Use the bubble sort to order the following array. After each pass 1 through 3, list the elements in their given order and give the current value of "lastExchangeIndex".
7 12 3 0 8 10 1
[0] [1] [2] [3] [4] [5] [6]
Pass 1: lastExchangeIndex_____ List: ______
Pass 2: lastExchangeIndex_____ List: ______
Pass 3: lastExchangeIndex_____ List: ______
What is the average case computational complexity of the bubble sort?
- O(n log2n)
- O(n2)
- O(n)
- O(n3)
- There is no difference between the best and worst case efficiency for the bubble sort?
- true
- false
- What is the computational complexity for the bubble sort when handling the best case?
- O(n log2n)
- O(n2)
- O(n)
- O(n3)
- Implement the insertion sort algorithm for the array
7 3 0 8 1
[0] [1] [2] [3] [4]
- How many passes are required for the sort?____
- Trace the first three passes and list the elements in their given order
Pass 1: List: ______
Pass 2: List: ______
Pass 3: List: ______
- In the best case what is the number of comparisions to order an array of 5 elements using the selection sort?_____
- 1
- 4
- 7
- 10
- In the worst case what is the number of comparisions to order an array of 5 elements using the insertion sort?
- 4
- 10
- 15
- 20
- What is the computational complexity of the insertion sort for
- The average case
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- The worst case_____
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- The best case
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- Use the quickest sort algorithm on the following 10 element array.
90 55 65 80 20 5 60 100
[0] [1] [2] [3] [4] 5[] [6] [7]
- In pass 1 what is the pivot value?_____
- In pass 1 indicate all pairs of elements that must be exchanged to move to their proper sublist
- At which index in the array is the pivot inserted?
- List the items in order after pass 1
Record the elements in the sublist after pass 1 in 14.9. (Note the sublist may have fewer than 7 elements)
___ ___ ___ ___ ___ ___ ___
[0] [1] [2] [3] [4] [5] [6]
- Use the Quicksort algorithm to complete a pass on this sublist. Give the ordering of these elements.
- The Quicksort algorithm uses recursion to sort both lower and upper sublists. In the recursive algorithm describe the stopping condition____
- Which situation represents the worst case for the Quicksort?
- The elements in ascending order
- The elements in descending order
- The pivot is the smallest element all of the time.
- The elements are in alternating small/large order.
- Which situation represents the best case for the Quicksort?
- The elements in ascending order
- The pivot is the smallest element all of the time.
- The elements are in random order
- The elements are in alternating small/large order.
- What is the computational complexity for the Quicksort for
- The average case_______
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- The worst case_____
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- The best case_____
- O(n log2n)
- O(n2)
- O(n)
- O(1)
- Which of the basic sort algorithms is most efficient when the list is initially ordered?
- selection
- insertion
- bubble
- ambiguous
- Which of the basic sort algorithms is most efficient when the list is initially given in reverse order?
- selection
- insertion
- bubble
- ambiguous