Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A[]={0,400,800,900,999} public static void mySort(int[] A, int p ,int q){ int[] scratch = new int[q-p+1]; for (int i = 0; i < A.length; i++) {
A[]={0,400,800,900,999}
public static void mySort(int[] A, int p ,int q){
int[] scratch = new int[q-p+1];
for (int i = 0; i < A.length; i++) {
scratch[A[i]-p] = A[i];
}
int counter = 0; // c=0
for (int i = 0; i < scratch.length; i++) { //i if (scratch[i] > 0){ //s[i]>0 A[counter] = scratch[i]; //A[c] = s[i] Counter++; //c++ } i need to find loop invariant and initialization, maintenance, and termination. at the moment I think the invariant is A(counter)=scratch[i] but Im not sure about invariants
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started