@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
@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
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.
This might be kind of a jerk question but how did strings make merging easier? I'm wondering what you were thinking.i am not using string anymore, as some1 mentioned above it is getting harder. but then do u know any simple merge function..!?
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
@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:
so as u may know and i came to know this doesnt work. must b a constant assignment.Code:mergesort(int a, int left, int right){ int b[right], ......... }
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.
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"
yeah, i am geting it now i gues, then can i use high as a global var. suggest a workaround maybe?