Menu

(Solved) : Assume Arrays Begin Index 0 Lines B Terminate Wheni B Equivalent Q28733497 . . .

Data STructures

Assume arrays begin with index 0, and lines such as for i - a to b terminate wheni> b, so it is equivalent to for (i = a; í <= b; i++). Consider the following pseudocode for insertionSort that contains bugs: 1. procedure insertionSort (A: an array of integers) 2. for i1 to A.size -1 4. while j < A.size and ALj] < ALj 1] 5. svap A[j], A[j1] 6. printf (i: %d j: %d A[1] : %d A[2] : %d A[3] : %d, i, j, A[1] , A[2] , A[3]) (a) 8 pts Fill the following table for values printed by insertionSort with A [1,5,8,9,3 Al1 A[2 A[3) b) 8 pts Use one sentence to explain how the table above indicates the pseudocode for insertionSort is wrong.

Assume arrays begin with index 0, and lines such as for i – a to b terminate wheni> b, so it is equivalent to for (i = a; í <= b; i++). Consider the following pseudocode for insertionSort that contains bugs: 1. procedure insertionSort (A: an array of integers) 2. for i1 to A.size -1 4. while j < A.size and ALj] < ALj 1] 5. svap A[j], A[j1] 6. printf (“i: %d j: %d A[1] : %d A[2] : %d A[3] : %d”, i, j, A[1] , A[2] , A[3]) (a) 8 pts Fill the following table for values printed by insertionSort with A [1,5,8,9,3 Al1 A[2 A[3) b) 8 pts Use one sentence to explain how the table above indicates the pseudocode for insertionSort is wrong. Show transcribed image text

Expert Answer


Answer to Assume Arrays Begin Index 0 Lines B Terminate Wheni B Equivalent Q28733497 . . .

OR