1. Engineering
  2. Computer Science
  3. please solve it without looking at the other zookal answers...

Question: please solve it without looking at the other zookal answers...

Question details

please solve it without looking at the other Zookal answers , proof it using k and k+1 ( induction ) make it clear please and what is the base case and induction case if needed

- use iterations as well , some of the examples we had in class contained 1st iteration and 2nd and so on...

Prove the following loop invariants about the CountingSort algorithm, below. Note that you do not need to prove that this algorithm is correct. Input: data: array of n integers that are between 1 and r Input: n: size of data Input: r: range of data Output: permutation of data such that data 1] data2| S < data[n] 1 Algorithm: CountingSort 2 count -Array(r 3 Initialize count to 0 4 for i 1 to n do 5count[datall count datali]]+ 1 6 end 7for j = 2 to r do 9 end 1o outputArray(n) 11 for「=1 to n do 12output count(datadatali 13 | countldata[i]]=count[data[i])-1 14 end 15 return output 1. Prove that countequals the number of times j appears in data[1..i], for every j from 1 up to r, after each iteration of the for loop in lines 4-6.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution