AkosiIU
Hello po paunlock po.
You do not have permission to view the full content of this post. Log in or register now.
Hello po paunlock po.
You do not have permission to view the full content of this post. Log in or register now.
Thank you po!Answer & Explanation
Solved by verified expert![]()
1. True or False
2. 6 comparisons
- True
- True
- True
- False
- True
3. 1st pass: 8 17 22 9 27 35 15 54 19 75
2nd pass: 8 9 22 17 27 35 15 54 19 75
3rd pass: 8 9 15 17 27 35 22 54 19 75
4th pass: 8 9 15 17 27 35 22 54 19 75
5th pass: 8 9 15 17 19 35 22 54 27 75
6th pass: 8 9 15 17 19 22 35 54 27 75
7th pass: 8 9 15 17 19 22 27 54 35 75
8th pass: 8 9 15 17 19 22 27 35 54 75
9th pass: 8 9 15 17 19 22 27 35 54 75
10th pass: 8 9 15 17 19 22 27 35 54 75
4. Initial array: 25 32 9 14 27 12
1st pass: 25 9 14 27 12 32
2nd pass: 9 14 25 12 27 32
3rd pass: 9 14 12 25 27 32
4th pass: 9 12 14 25 27 32
5th pass: 9 12 14 25 27 32
5. In the case of quick sort, the partitioning is done based on finding the pivot element and then dividing the list into two parts and left side of the pivot element will be less than the pivot element and the right side elements are to be greater than pivot element.
Whereas in the case of merge sort, we divide the list into two parts and divide it until we are left with single element and then merge the small size lists to bigger size lists.
Step-by-step explanation
1. True or False
- It is true that we sort the list by finding the minimum element of the list and then putting it to the index i. thus the above statement is true.
- In both of the cases, we partition the list and sort the list by partitioning the list.
- It is true that we divide the list into two parts recursively and then divide it until the list size is reduced to size 1 and then we merge the small size lists.
- It is false as bubble sort and insertion sort are of equal complexity.
- This is the correct time complexity for insertion sort, bubble sort and selection sort, thus above statement is true.
2. There are total of 6 comparisons that are needed to make 30 reach its correct location. 25 37 42 30 58 45,
index 1: comparison with 37: 1
index 2: comparison with 42: 2
index 3: comparison with 30: 3
total comparison: 1+2+3 = 6
3. Initial list: 17 8 22 9 27 35 15 54 19 75
1st pass: 8 17 22 9 27 35 15 54 19 75
2nd pass: 8 9 22 17 27 35 15 54 19 75
3rd pass: 8 9 15 17 27 35 22 54 19 75
4th pass: 8 9 15 17 27 35 22 54 19 75
5th pass: 8 9 15 17 19 35 22 54 27 75
6th pass: 8 9 15 17 19 22 35 54 27 75
7th pass: 8 9 15 17 19 22 27 54 35 75
8th pass: 8 9 15 17 19 22 27 35 54 75
9th pass: 8 9 15 17 19 22 27 35 54 75
10th pass: 8 9 15 17 19 22 27 35 54 75
In the case of selection sort, we need to find the minimum value and then put it at the index i. In this way, we can sort the list using selection sort.
4. Initial array: 25 32 9 14 27 12
1st pass: 25 9 14 27 12 32
2nd pass: 9 14 25 12 27 32
3rd pass: 9 14 12 25 27 32
4th pass: 9 12 14 25 27 32
5th pass: 9 12 14 25 27 32
In the case of bubble sort we need to go for n-1 passes and thus there are 5 passes in which we are sorting the given list. In each step we go through the the complete list and compare j and j+1 element.
Thus this way, we can sort the given list.
5. In the case of quick sort, we partition the list by finding the pivot element and then moves the elements smaller than pivot element to its left and greater element to its right.
In the case of merge sort, we partition the list by dividing the list into two parts and divide the lists until the size of list is 1 and then we merge the sorted small size lists into full size list.
Paunlock po sakin With answer sana You do not have permission to view the full content of this post. Log in or register now.Answer & Explanation
Solved by verified expert![]()
1. True or False
2. 6 comparisons
- True
- True
- True
- False
- True
3. 1st pass: 8 17 22 9 27 35 15 54 19 75
2nd pass: 8 9 22 17 27 35 15 54 19 75
3rd pass: 8 9 15 17 27 35 22 54 19 75
4th pass: 8 9 15 17 27 35 22 54 19 75
5th pass: 8 9 15 17 19 35 22 54 27 75
6th pass: 8 9 15 17 19 22 35 54 27 75
7th pass: 8 9 15 17 19 22 27 54 35 75
8th pass: 8 9 15 17 19 22 27 35 54 75
9th pass: 8 9 15 17 19 22 27 35 54 75
10th pass: 8 9 15 17 19 22 27 35 54 75
4. Initial array: 25 32 9 14 27 12
1st pass: 25 9 14 27 12 32
2nd pass: 9 14 25 12 27 32
3rd pass: 9 14 12 25 27 32
4th pass: 9 12 14 25 27 32
5th pass: 9 12 14 25 27 32
5. In the case of quick sort, the partitioning is done based on finding the pivot element and then dividing the list into two parts and left side of the pivot element will be less than the pivot element and the right side elements are to be greater than pivot element.
Whereas in the case of merge sort, we divide the list into two parts and divide it until we are left with single element and then merge the small size lists to bigger size lists.
Step-by-step explanation
1. True or False
- It is true that we sort the list by finding the minimum element of the list and then putting it to the index i. thus the above statement is true.
- In both of the cases, we partition the list and sort the list by partitioning the list.
- It is true that we divide the list into two parts recursively and then divide it until the list size is reduced to size 1 and then we merge the small size lists.
- It is false as bubble sort and insertion sort are of equal complexity.
- This is the correct time complexity for insertion sort, bubble sort and selection sort, thus above statement is true.
2. There are total of 6 comparisons that are needed to make 30 reach its correct location. 25 37 42 30 58 45,
index 1: comparison with 37: 1
index 2: comparison with 42: 2
index 3: comparison with 30: 3
total comparison: 1+2+3 = 6
3. Initial list: 17 8 22 9 27 35 15 54 19 75
1st pass: 8 17 22 9 27 35 15 54 19 75
2nd pass: 8 9 22 17 27 35 15 54 19 75
3rd pass: 8 9 15 17 27 35 22 54 19 75
4th pass: 8 9 15 17 27 35 22 54 19 75
5th pass: 8 9 15 17 19 35 22 54 27 75
6th pass: 8 9 15 17 19 22 35 54 27 75
7th pass: 8 9 15 17 19 22 27 54 35 75
8th pass: 8 9 15 17 19 22 27 35 54 75
9th pass: 8 9 15 17 19 22 27 35 54 75
10th pass: 8 9 15 17 19 22 27 35 54 75
In the case of selection sort, we need to find the minimum value and then put it at the index i. In this way, we can sort the list using selection sort.
4. Initial array: 25 32 9 14 27 12
1st pass: 25 9 14 27 12 32
2nd pass: 9 14 25 12 27 32
3rd pass: 9 14 12 25 27 32
4th pass: 9 12 14 25 27 32
5th pass: 9 12 14 25 27 32
In the case of bubble sort we need to go for n-1 passes and thus there are 5 passes in which we are sorting the given list. In each step we go through the the complete list and compare j and j+1 element.
Thus this way, we can sort the given list.
5. In the case of quick sort, we partition the list by finding the pivot element and then moves the elements smaller than pivot element to its left and greater element to its right.
In the case of merge sort, we partition the list by dividing the list into two parts and divide the lists until the size of list is 1 and then we merge the sorted small size lists into full size list.