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
  • Convert the Convergent-Pointer Algorithm pseudo code to C code. Use exact variables and make no modifications....

    Convert the Convergent-Pointer Algorithm pseudo code to C code. Use exact variables and make no modifications. Get values for n and the n data items Set the value of legit to n Set the value of left to 1 Set the value of right to n While left is less than right do 1 If the item at position left is not 0 then Increase left by 1 Otherwise Reduce legit by 1 Copy the item at position right into...

  • I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write...

    I need this in Net beans and not Python. Part 1 - Pseudo-code Design and write the pseudo-code for the following Problem Statement. Problem Statement A company gives its employees an that will provide one of 3 results based on the following ranges of scores: Score Message on Report 90-100 Special Commendation 70-89 Pass Below 70 Fail Design a single If-Then-Else structure using pseudo-code which displays one of these messages based a score input by a user. Be sure your...

  • 1. In Python, Write a function to convert inches into yards, feet and inches. The functions...

    1. In Python, Write a function to convert inches into yards, feet and inches. The functions should take one parameter, 'inches', and print out the number of yards, feet, and inches equivalent to the value of the argument. Call the function after prompting the user to enter the number of inches. Don't forget to convert the input to an 'int'. 2. In Python,Write a function to convert celsius to fahrenheit. The function should return a value, which you should assign...

  • Write an pseudo code floor(A key) method for B tree.The function floor returns the biggest key...

    Write an pseudo code floor(A key) method for B tree.The function floor returns the biggest key smaller or equal to key.

  • its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program...

    its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...

  • x86 intel assembly language instruction should be used. 3. What this pseudo-code does? And convert it into Assembly. prime( 1):#2: prime[2] :#3: {first prime number} {second prime number) candidat...

    x86 intel assembly language instruction should be used. 3. What this pseudo-code does? And convert it into Assembly. prime( 1):#2: prime[2] :#3: {first prime number} {second prime number) candidate-5 (first candidate for a new prime number) while primeCount< 100 loop ndex:1 while (index < primeCount) and (prime[index] does not evenly divide candidate) loop add 1 to index end while if (index > primeCount) then (no existing prime evenly divides the candidate, so it is new prime) add 1 to primeCount;...

  • Write pseudo code that will read in 3 numbers that a user enters, pass them to...

    Write pseudo code that will read in 3 numbers that a user enters, pass them to a module that will calculate the average of the 3 numbers and display them OR Write pseudo code that will read in 3 numbers that a user enters, pass them to a function that will calculate the average of the 3 numbers and return it to the main module. Display the average in the main module.

  • IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is...

    IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is a list of non-empty strings. If each string in the list starts with a capital letter, then the function should return the value True. If some string in the list does not start with a capital letter, then the function should return the value False You may use any of the string functions that are available in Python in your solution, so you might...

  • modify the code for timer_test_02.c to allow the time delay between events to be pseudo- random...

    modify the code for timer_test_02.c to allow the time delay between events to be pseudo- random exponential, with a mean time between arrivals of 0.1 second. Change the limit in the time_stamps() function from 5 time-stamps to 10, so that the mean run-time will be about 10*0.1 = 1.0 seconds. Once this is working, you should be able to generate 10 events with a pseudo-random exponential arrival process. The code is: #include <stdio.h> #include <stdint.h> #include <time.h> #include <unistd.h> #include...

  • Need help with Python (BinarySearch), code will be below after my statements. Thank you. Have to...

    Need help with Python (BinarySearch), code will be below after my statements. Thank you. Have to "Add a counter to report how many searches have been done for each item searched for." Have to follow this: 1) you'll create a counter variable within the function definition, say after "the top = len(myList)-1" line and initialize it to zero. 2) Then within the while loop, say after the "middle = (bottom+top)//2" line, you'll start counting with "counter += 1" and 3)...

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
ADVERTISEMENT