Hey I just need help with both of this quesition, thanks you so much! 1-Use the
ID: 3824988 • Letter: H
Question
Hey I just need help with both of this quesition, thanks you so much!
1-Use the Bubble sort to show the 1st four passes through the loop of a bubble sort. Use arrows and/or comments to show when and where a swap is made. Display the current state of the array at the end of each pass through the loop. Tell me whether the array is sorted by Pass 4.
Original Array: 23, -2, -6, 12, 48, -1, 0, 19, 29
and for this question
Suppose we have an array declared as follows: int data[8];
Write a line of code that sets the first element of the array to 314. I said a[0] would I be right
Thanks alot!
Explanation / Answer
Original Array: 23, -2, -6, 12, 48, -1, 0, 19, 29
Pass 1:
-2, 23, -6, 12, 48, -1, 0, 19, 29
swap : 23 -2
-2, -6, 23, 12, 48, -1, 0, 19, 29
swap : 23 -6
-2, -6, 12, 23, 48, -1, 0, 19, 29
swap : 23 12
-2, -6, 12, 23, -1, 48, 0, 19, 29
swap : 48 -1
-2, -6, 12, 23, -1, 0, 48, 19, 29
swap : 48 0
-2, -6, 12, 23, -1, 0, 19, 48, 29
swap : 48 19
-2, -6, 12, 23, -1, 0, 19, 29, 48
swap : 48 29
Pass 2:
-2, -6, 12, 23, -1, 0, 19, 29, 48
-2, -6, 12, -1, 23, 0, 19, 29, 48
swap 23 -1
-2, -6, 12, -1, 0, 23, 19, 29, 48
swap 23 0
-2, -6, 12, -1, 0, 19, 23, 29, 48
swap 23 19
Pass 3:
-2, -6, 12, -1, 0, 19, 23, 29, 48
-2, -6, -1, 12, 0, 19, 23, 29, 48
swap -1 12
-2, -6, -1, 0, 12, 19, 23, 29, 48
swap 12 0
Pass 4:
-2, -6, -1, 0, 12, 19, 23, 29, 48
Part 2)
int data[8];
data[0] = 314;