# Mergesort error!!

This is a discussion on Mergesort error!! within the C Programming forums, part of the General Programming Boards category; @I MALC NO i need to get this, right is divide /2 and hence will be <=1. so while loop ...

1. @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. i am not using string anymore, as some1 mentioned above it is getting harder. but then do u know any simple merge function..!?

3. 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. @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. Originally Posted by Samarth KV
@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.

6. yeah, i am geting it now i gues, then can i use high as a global var. suggest a workaround maybe?

Page 2 of 2 First 12
Popular pages Recent additions