Sorting


For this lab we will do 3 variants of the bubble sort Sort1 a basic bubble sort for ( 0 to N) for ( 0 to N-1) compare two adjacent items and swap if necessary basically requires N squared iterations, always the same Sort2 for ( 0 to N) for ( 0 to (starts with N but decrements each time )) compare two adjacent items and swap if necessary basically requires (n(n+1))/2 iterations, always the same Sort3 same basic logic as Sort2 but if a complete pass is made through the array without swapping any items it is sorted so break from the loop for ( 0 to N) { for ( 0 to (starts with N but decrements each time )) compare two adjacent items and swap if necessary if ( you did not swap any values in the last for loop) break; } basically <= (n(n+1)/2 iterations, can vary greatly depending on how unsorted the target is Sort4 same basic logic as Sort3 you will compare array postion 0 with 1 then 2 then 3 then 4 and so on to the end you will then compare positon 1 with 2 then 3 then 4 then 5 and so on to the end you will then compare postiton 2 with 3 then 4 then 5 then 6 ans so on to the end for ( 0 to N ) as outerloop { for ( outerloop +1 to N ) as innerloop { compare position outerloop with position innerloop if ( you did not swap any values in the last for loop) break; } } Two test mains have been provided to test your functions, make your output match the examples