Question: Unit 4 Assignment 3: Coding Project (Quick Sort) Scenario Use the studentGrades array from task 1. Implement a quicksort that will sort the grades highest
Unit 4 Assignment 3: Coding Project (Quick Sort)
Scenario
Use the studentGrades array from task 1. Implement a quicksort that will sort the grades highest to lowest and lowest to highest.
Create one method called sortArrayDes(). Implement a quicksort algorithm that will sort from highest to lowest.
Create a second method called sortArrayAsc(). Implement a quicksort algorithm that will sort from lowest to highest.
Create a third method called printArray, which will display the results of both sorts.
Expected Output
Quicksort Descending
98 97 95 90 88 78 75 65 56 55
Quicksort Ascending
55 56 65 75 78 88 90 95 97 98
This is what I have so far (I use C#):
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApp45 { public static class QuickSort { public static void Sort
do { while (array[i].CompareTo(pivot) < 0) { i++; } while (array[j].CompareTo(pivot) > 0) { j--; } if (i >= j) { break; } Swap(array, i, j); } while (i <= j); return j; }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
