Recent content by abacus

  1. A

    Randomized Quick Sort: Code & Run Time

    I don't know how to use a debugger as for the example you posted in only shows whatever I had inputed randQuickSort(k, value,value)
  2. A

    Randomized Quick Sort: Code & Run Time

    I was thinking 0 and 9, but that had the same effect.
  3. A

    Randomized Quick Sort: Code & Run Time

    I thought that would somehow call the positions of the left and right.
  4. A

    Randomized Quick Sort: Code & Run Time

    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() {...
  5. A

    Randomized Quick Sort: Code & Run Time

    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...
  6. A

    Randomized Quick Sort: Code & Run Time

    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.
  7. A

    Randomized Quick Sort: Code & Run Time

    Yeah I guess it's not working. *updated below
  8. A

    Randomized Quick Sort: Code & Run Time

    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) {...
  9. A

    Randomized Quick Sort: Code & Run Time

    so I can just set Object pivot = rand(); ?
  10. A

    Randomized Quick Sort: Code & Run Time

    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) {...
  11. A

    Insert & Remove Functions for Doubly Linked List

    Thanks for the tip maverick280857
  12. A

    Insert & Remove Functions for Doubly Linked List

    Thanks I got it to work in a way.
  13. A

    Insert & Remove Functions for Doubly Linked List

    why? What steps am I missing? I just want it to insert at the beginning.
  14. A

    Insert & Remove Functions for Doubly Linked List

    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...
  15. A

    Insert & Remove Functions for Doubly Linked List

    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:
Back
Top