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, 22.06.2019 10:30
Dave has to create animations for a game. which tool can dave use?
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
What is the original authority for copyright laws
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
question
Computers and Technology, 23.06.2019 23:40
Which of the following calculates the total from the adjacent cell through the first nonnumeric cell by default, using the sum function in its formula? -average -autosum -counta -max
Answers: 1
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: 13722359