Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Recursive *Quick Sort* THIS IS THE THIRD TIME I Post THIS QUESTION. PLEASE READ CAREFULLY. I need FULLY FUNCTIONAL CODE. NOT THEORY based responses.

C++ Recursive *Quick Sort*

THIS IS THE THIRD TIME I Post THIS QUESTION. PLEASE READ CAREFULLY. I need FULLY FUNCTIONAL CODE. NOT THEORY based responses. 1. Please modify the PARTITION function below so that the array gets sorted from least to greatest. 2. pass the quickSort function an array with the following values: 5, 2, 6, 1, 3, 4 ... run the program and show a screenshot showing that it works.

double arr[] = {5, 2, 6, 1, 3, 4};

quickSort(arr, 0, 6);

for (int i = 0; i

Thank YOU!!!

PS: do not change the pivot. Our pivot must be the first element of the array. (what I mean by this is, that there different ways to choose a pivot. You can select a random pivot, make the middle number your pivot, or the last number of the array your pivot... etc... for this assigment, we are required to choose the first number in the array as our pivot)

image text in transcribed

//--------------------------------

#include using namespace std;

//5, 2, 6, 1, 3, 4 int partition (double * arr, int start, int end) { int pivot = arr[start]; // pivot int i = (start-1); for (int j = end-1; j >= start; --j) { if (pivot >= arr[j]) { i++; swap(arr[i], arr[j]); } } swap(arr[i + 1], arr[end]); return (i + 1); }

void quickSort(double * arr, int start, int end) { if ((end-start)

quickSort(arr, start, pi - 1); quickSort(arr, pi + 1, start); } }

int main() {

double arr[] = {5, 2, 6, 1, 3, 4};

quickSort(arr, 0, 6);

for (int i = 0; i

}

#include using namespace std; 6 /15, 2, 6, 1, 3, 4 int partition (double arr, int start, int end) 2 4 5 int pivot - arr[start]; // pivot int i = (start-1); I for (int j - end-1; j >- start; --j) if (pivot >= arr[j]) swap(arr[i], arr[j]); swap (arr[i 1], arr[end]); return (i + 1); void quicksort(double arr, int start, int end) if ((end-start) 1) //do nothing else int pi partition(arr, start, end); quickSort(arr, start, pi - 1); quickSort(arr, pi 1, start)

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Collect a small sample of about

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago