Question

Convert this pseudo code into python 3: function msort(A,start,stop)      if start >= stop then            ...

Convert this pseudo code into python 3:

function msort(A,start,stop)

     if start >= stop then

            return

     end if

     Set middle = start+floor( (stop-start)/2 )

     msort(A,start,middle)

     msort(A,middle+1,stop)

     merge(A,start,middle,stop)

end function

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here implementation for merge function is not given so it is kept blank.

Other implementation is as follow.

import math
def msort(A,start,stop):
if start>=stop:
return #end if
middle = start + math.floor((stop-start)/2) #calculate middle
msort(A,start,middle) #recusrsive call to msort
msort(A,middle+1,stop) #recursive call to msort
merge(A,start,middle,stop) #method calling
  

#method definition for merge
def merge(A,start,middle,stop):
return

A=[2,6,3,98,45] #initialize the array
msort(A,0,4) #mehod calling

Add a comment
Know the answer?
Add Answer to:
Convert this pseudo code into python 3: function msort(A,start,stop)      if start >= stop then            ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT