Thread: Mergesort error!!

  1. #16
    Registered User
    Join Date
    May 2012
    Posts
    13
    @I MALC NO i need to get this, right is divide /2 and hence will be <=1. so while loop should not have a prob. thanks a lot for the help by the way

  2. #17
    Registered User
    Join Date
    May 2012
    Posts
    13
    i am not using string anymore, as some1 mentioned above it is getting harder. but then do u know any simple merge function..!?
    Last edited by Samarth KV; 05-20-2012 at 03:33 AM.

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    i am not using string anymore, as some1 mentioned above it is getting harder. but then do u know any simple merge function..!?
    This might be kind of a jerk question but how did strings make merging easier? I'm wondering what you were thinking.

    Our parent site actually has a tutorial on merge sort, it even links to a working implementation, so you might as well read that. Here: Merge Sort - Cprogramming.com

  4. #19
    Registered User
    Join Date
    May 2012
    Posts
    13
    @whiteflags: thank you atlast my soul can rest ... stupid coll teacher made one wrong assignment and now i had to go thru all this. the code was this:

    Code:
     mergesort(int a, int left, int right){
    int b[right], .........
    }
    so as u may know and i came to know this doesnt work. must b a constant assignment.

    and my plan was so crazy, i wanted put the number in its rightfull place but into a string. like "33 45 56 67 73" one by one. 70 goes inbtween 67 and 73, but inside the string. i dont know what i was thinking now tat it is fail.

  5. #20
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Samarth KV View Post
    @I MALC NO i need to get this, right is divide /2 and hence will be <=1. so while loop should not have a prob. thanks a lot for the help by the way
    FYI: I've written 100s of recursive functions in C & C++ in the last 10 years, more than one of which was a variant of merge sort.
    If you think it's not an infinite loop then that probably just means you don't understand recursion.
    You're talking about the calculation for mid, and mid is not h.

    I might have time to explain better later, but for now I have to go to work.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #21
    Registered User
    Join Date
    May 2012
    Posts
    13
    yeah, i am geting it now i gues, then can i use high as a global var. suggest a workaround maybe?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ MergeSort
    By Jesse20ghet in forum C++ Programming
    Replies: 14
    Last Post: 06-15-2011, 01:24 PM
  2. my mergeSort
    By Soulzityr in forum C Programming
    Replies: 41
    Last Post: 03-29-2010, 12:27 PM
  3. Mergesort in C
    By Oduig in forum C Programming
    Replies: 2
    Last Post: 09-14-2008, 11:30 AM
  4. Mergesort
    By swanley007 in forum C++ Programming
    Replies: 6
    Last Post: 10-26-2005, 11:45 PM
  5. mergesort
    By AmazingRando in forum C++ Programming
    Replies: 14
    Last Post: 02-29-2004, 09:35 AM

Tags for this Thread