Answered step by step
Verified Expert Solution
Question
1 Approved Answer
document this Java program using JML assertions (i.e., invariant, requires, ensures, assignable, ...). // From http://gauss.ececs.uc.edu/Courses/C321/html/quicksort.java.html import java.io.*; import java.util.*; public class QuickSort { public
document this Java program using JML assertions (i.e., invariant, requires, ensures, assignable, ...).
// From http://gauss.ececs.uc.edu/Courses/C321/html/quicksort.java.html import java.io.*; import java.util.*; public class QuickSort { public static void swap (int A[], int x, int y) { int temp = A[x]; A[x] = A[y]; A[y] = temp; } public static int partition(int A[], int f, int l) { int pivot = A[f]; while (f < l) { if (A[f] == pivot || A[l] == pivot) { // for you to fill this out } while (A[f] < pivot) f++; while (A[l] > pivot) l--; swap (A, f, l); } return f; } public static void Quicksort(int A[], int f, int l) { if (f >= l) return; int pivot_index = partition(A, f, l); Quicksort(A, f, pivot_index); Quicksort(A, pivot_index+1, l); } public static void main(String argv[]) { int A[] = new int[argv.length]; for (int i = 0 ; i < argv.length ; i ++) A[i] = Integer.parseInt(argv[i]); Quicksort(A, 0, argv.length-1); for (int i = 0 ; i < argv.length ; i ++) System.out.print(A[i] + " "); System.out.println(); } }
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