Question: Lab Task (Bubble Sort) For this lab task you have given the following unsorted array A = {5,3,0,1,9,7,6,4,2,8} Now, we have to sort this array

 Lab Task (Bubble Sort) For this lab task you have given

Lab Task (Bubble Sort) For this lab task you have given the following unsorted array A = {5,3,0,1,9,7,6,4,2,8} Now, we have to sort this array with the help of Bubble Sort such that in case the odd elements shall be sorted in the prime number indices and the even number shall be sorted next to each other like. Sorted Array according to the condition: Sorted Array: => A = {0,2,1, 3, 4, 5, 6, 7, 8} Now, the 9 is not in the list because there is no prime position left for 9 in the list. As you are seeing that all the odd elements are sorted in prime number indices which are 1,3,5,7 1 is placed in 2nd position because 2 is a prime number, 3 is placed in 3rd position because 3 is also a prime number and so on... Array = {10, 21, 77, 8, 6, 12, 19,2,3,6, 71, 66,55 , 13} Now, you have to sort it according to the conditions given above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!