subject

;to bubble sort, you need to scan the array n-1 times, ; in every scan, you compare from top down each two consecutive elements, and you swap them if they are not in ascending order. ; notice that in the first scan you get the largest element (no matter where it is in the array) pushed all the way to the bottom. ; so your next scan should be n-1 iterations, and then n-2 and so on. ; so every time you come back to the top of the array for a new scan, your n (the number of comparisons) must be decremented by 1. ; in the last scan, you need only one comparison. ; hints: ; your sorting algorithm starts with r6 as a pointer to the array ; you need to save n (number of elements) in r8, then decrement it by 1 (n-1) to become the number of comparisons. ; copy r6 to r7 so you keep r6 unchanged as it points to the top of the array for every new scan. ; copy n-1 to r9 and use r9 as a loop counter, while keeping the current n-1 value in r8 for the next scan. ; in the scan loop get an element and auto increment pointer r7, then get next element without changing r7. ; compare the two elements, if not in ascending order, swap them. ; repeat the scan from the top as pointed to by (r6), and every time decrement the number of comparisons (r8).

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 11:00
How should you specify box sizes on a web page if you want the boxes to vary according to the font size of the text they contain? a. in pixels b. in inches c. as percentages d. in em units
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
question
Computers and Technology, 23.06.2019 22:50
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
You know the right answer?
;to bubble sort, you need to scan the array n-1 times, ; in every scan, you compare from top down ea...
Questions
Questions on the website: 13722367