Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions