Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

1-4 How will MIS help my career?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

=+ Who do you think is right? Why?

Answered: 1 week ago