Search:

Type: Posts; User: deathslice

Page 1 of 10 1 2 3 4

Search: Search took 0.01 seconds.

  1. How to resolve two threads that are always waiting for each other

    Problem Information:

    So I have this school assignment that requires to synchronize an array of pthreads of size N that represents the number of students vs a single pthread that represents the...
  2. Why don't you take a look at an algorithm called...

    Why don't you take a look at an algorithm called median of medians that is based on the quick select algorithm with a worst case of big-oh(N).

    Wikipedia has a pseudocode section that you can look...
  3. Replies
    5
    Views
    1,953

    Damn it that was the problem. XD thanks guys.

    Damn it that was the problem. XD thanks guys.
  4. Replies
    5
    Views
    1,953

    Cool but the website that has this challenge said...

    Cool but the website that has this challenge said that it produces the wrong answer. HackerRank
  5. Replies
    5
    Views
    1,953

    Reversing a Linked List

    I've been trying to reverse a linked list but I'm not sure if this piece of code that I made does what I think it does. The process in my mind is, create a empty node that will be returned as our...
  6. oops, can a moderator change the title of this...

    oops, can a moderator change the title of this thread to "How to execute specific targets based on a gcc flag(-D) in the Makefile". Don't know what happen there.
  7. How to execute specific targets based on a gcc flag(-D) in the Makefile

    So my goal as of now is to be able to compile my program under a flag(-D) if and only the user does make -D. If the user simply does make, then compile the program without the -D flag. The problem...
  8. True, I might as well do that since I can't do...

    True, I might as well do that since I can't do this a[1][1] with void **.
  9. Algorism, Like I said it's y * rows + x if you...

    Algorism, Like I said it's y * rows + x if you are going to display the matrix in column major order and x * columns + y if you are going to display it in row major order(you can verify yourself with...
  10. You have to remember that we are working with...

    You have to remember that we are working with void pointers and so we must multiple the offset by the size of the data type which is not provide by the void type.
  11. The formula is correct. Yours is almost correct;...

    The formula is correct. Yours is almost correct; it's y * rows + x. That formula is only if you want your Matrix to be display in column major order not row major order which is what I'm doing(C is...
  12. SegFault after I try to free my generic matrix structure

    I've debugged my program and every time it reaches to free the memory blocks that I allocated, it crashes. I've made sure that I deallocated my memory the exact same way I allocated it but it still...
  13. Interesting suggestion salem, I could add an...

    Interesting suggestion salem, I could add an additional two variables called leftSideLength and rightSideLength. Then I would need to count the number of comparisons from the left and right side and...
  14. Any optimizations I could make to my generic merge sort?

    Besides using insertion sort when my array becomes nearly sorted, what other optimizations could I make to my code that would improve the run time of my program? Doesn't have to be the merge sort...
  15. Guys I'm having trouble implementing my generic...

    Guys I'm having trouble implementing my generic insertion sort. That first thing I noticed was that I was comparing negative numbers because I was using a char ptr which obviously could not point to...
  16. Whiteflags, I said in my previous post(more than...

    Whiteflags, I said in my previous post(more than likely you read it before I edited it) that you didn't need to explain why it crashed. At this moment I would to like to know how qsort deals with...
  17. So how does qsort deals with arrays of different...

    So how does qsort deals with arrays of different dimensions since this line of code



    return strcmp(*(const char **)a, *(const char **)b);


    crashes my program if use a 1D array(no need to...
  18. Well I made some modifications to my code like...

    Well I made some modifications to my code like removing my is_sorted function for the moment. That might be what is causing the problem because at the end it would not sort it completely because...
  19. I'm assuming that what your byteswap function...

    I'm assuming that what your byteswap function does is tmp holds one byte of information from aa, bb transfer one byte to aa, and then tmp gives one byte of information to bb. This cycle repeats...
  20. That is weird. I used the comparison function in...

    That is weird. I used the comparison function in post 3 and it sorted it just fine.
  21. Alright I figured out my problem. The problem was...

    Alright I figured out my problem. The problem was that once my array was finally sorted before calling the final quick sort, the changes did not stick and so the output was not fully sorted. Plus...
  22. Here is an example of me calling cmp and then...

    Here is an example of me calling cmp and then maybe you can tell me if I'm doing it right



    if(cmp(&carray[i * memSize], &carray[i + 1 * memSize]) > 0)
    {
    return 0;
    }
  23. Wouldn't it just be const char *? why are you...

    Wouldn't it just be const char *? why are you casting it to a double ptr and deferencing it to a single ptr? why not just



    return strcmp((const char *)a, (const char *)b);


    If you must...
  24. Ok at least now I know it has to do with the way...

    Ok at least now I know it has to do with the way I'm offsetting the memory because I used strcmp and it still did not sort it(but it did with integers). At least know I my swap, cmp and quick sort...
  25. Alright I've changed my cmp Function to this. ...

    Alright I've changed my cmp Function to this.



    int cmp(const void *a, const void *b)
    {
    const int *A = a, *B = b;
    return (*A > *B) - (*A < *B);
    }
Results 1 to 25 of 228
Page 1 of 10 1 2 3 4