0
Why the loop never ends ? How to fix it ?
This is implementation of merge sort and this is my own method , I know that it is often implemented by using recrusion . The problem is that it shows no output , that means the while loop never terminates . Please show me how can I fix it ... https://pastebin.ubuntu.com/p/WCXKPy494B
14 Answers
+ 3
I don't rate codes...
I try to debug them...
I know that you're coding for competitive challenge, but I haven't looked your code in details and I'm not really aware of sorting algorithms: my rate would have really few interest ;P
+ 2
copy your code in sololearn playground, and paste the link to it... that would be more easy to help you ^^
0
visph https://code.sololearn.com/c12a5A0a22A1/?ref=app
Here you are Visph ... I haven't used recrusion this time =) and you may find it too complex ... please just consider the merge sort part , other parts work properly .
0
what is the use of second argument of merge_sort function? I didn't see where it is used?
anyway, your code produce no output because you don't call any of the defined functions... and there's no global script to run ^^
calling merge_sort with an array and any value, such as:
print(merge_sort([5,3,8,1],'foobar'))
seems to always return (and print) an empty array ;P
0
visph Ummm I just pasted the functions , you can use the merge sort like the way you just mentioned . It will show no output.. see the code again . It only outputs [] .. i dont understand which part deletes elements of the list ..
0
only outputing empty list is different to showing no output...
0
visph im still trying to fix it . This code is not my initial code ... the initial one does not even show the empty list . I edited that , and this one shows only an empty list
0
your two calls to clear() method delete the content newly appended... remove these two lines and your merge sort works fine ;)
0
lines 46 and 35
0
visph thank you so much gentleman ;)
And a quick question , how do you rate my code ? As I did not use recrusion ...
does it almost have the same quality(considering time complexity) as other usual ones have ? (those which use recrusion)
0
visph okay ... thanks .
0
Loop is a example like a : put the water bucket while it is not full
Like that we written a range and it stop of end of the last digit of the range
0
For stopping a loop you can use break function and enter the value on which you want to stop the loop.