Question: ARM Assembly Bubble Sort Ascending Order Instructions: Store the following number sequence on stack: {10, 8, 5, 4, 6, 3, 2, 0} Write a FOR

ARM Assembly Bubble Sort Ascending Order

Instructions:

  1. Store the following number sequence on stack: {10, 8, 5, 4, 6, 3, 2, 0}
  2. Write a FOR loop to implement bubble sort on the array above and arrange it in ascending order.
  3. Remember to pop out all values from the stack at the end of your code.

I need to be able to compare 2 numbers on a stack and get a for loop to sort the numbers in ascending order.

Example: starting with 10

10, 8, 5, 4, 6, 3, 2, 0

8, 10, 5, 4 ,6 ,3 , 2, 0

8, 5, 10, 4, 6, 3, 2, 0

8, 5, 4, 10, 6, 3, 2, 0

all the way until you get 8, 5, 4, 6, 3, 2, 0, 10 and sort out the first numbers from there on to eventually get

0, 2, 3, 4, 5, 6, 8, 10.

this is the c++ logic

void bubbleSort(int arr[], int n)

{

int i, j;

for (i = 0; i < n-1; i++)

// Last i elements are already in place

for (j = 0; j < n-i-1; j++)

if (arr[j] > arr[j+1])

swap(&arr[j], &arr[j+1]);

}

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!