I think I'm getting close, now there are no memory errors and it outputs something, but it outputs the order I inputted.
#include <iostream>
using namespace std;
void quickSort(int numbers[], int array_size);
void randQuickSort(int numbers[], int left, int right);
int main()
{...
Sorry, I thought that calling on the values would have indicated the positions. How would I call on the positions l, r or would I need to declare the two ints in main first?
Right now I seem to compile without error, some warnings, and there seems to be a memory leak.
#include...
randQuickSort(k, k[0], k[9]); would saying k[0](left) and k[9] (right) signify their positions in the array?
The error I keep getting is randQuickSort identifier not found.
so something like this?
void RandQuickSort(int Array[], int l, int r) {
int piv=l+(rand()%(r-1+1);
swap(Array[1],Array[piv]);
int i = l+1;
int j = r;
while (1) {
while(Array[i] <= Array[1] && i<r) ++i;
while (Array[j] <= Array[l] && j>l) –-j;
if (i >=j) {...
My textbook has the following code as a Quick Sort. It also discusses a randomized quick sort which should have a faster run time, but doesn't show the code for it. What would the code be like? Is only the pivot changed?
void quickSortStep(Sequence& S, int leftBound, int rightBound) {...
Thanks mav and brian,
So far I got the insert to work I believe.
void insert(cNode*& head, int n) {
cNode *newNode;
newNode = new cNode;
newNode->data = n;
newNode->next = head;
head = newNode;
}
The remove function is a bit tricky since I want whatever I input as my c-th node...
I'm using a struct.
Yeah I believe I made a typo for the remove function i didn't want to pass head to tail, it's head to node.
for Insert I had this, but I'm getting errors: