Question: Do the following tasks: i . Design and implement an efficient algorithm that computes the OSR metric for the MCM Problem's DP solution and generates
Do the following tasks:
i Design and implement an efficient algorithm that computes the OSR metric for the MCM Problem's DP solution and generates the OSR metric table up to an entered table size See the sample output below pts
ii Analyze your algorithm's time complexity by making comments about it There is no need for line by line analysis. pts
SAMPLE OUTPUT:
Enter table size:
Reference:
Cormen, T Leiserson, C Rivest, R and Stein, C Introduction to Algorithms Third Edition The MIT Press, ISBN:
PS:
You are required to work either alone or in at most threeperson groups.
If you wish to work as a group, all the group members should send an email furkanbakal@atilim.edu.tr indicating the name of hisher agreed group member until Sunday Hr:: Otherwise, it is assumed that you will work alone by default
Note that besides submitting the homework, you are also required to attend code review & demonstration of your code.
Percentages of written part submission and demo parts are and of your overall Homework # grade, respectively. Submissions without code review & demonstrations gets mathbfzero grade from both parts, directly.
Time table for the code review & demos to be announced later via course Moodle site.
For Part you can prefer any one of the programming languages mathbfCmathbfCor Python as your implementation language. Do NOT submit a screen shot of your source code but submit it as a text file!!!
Your answer for Part mathbf should be submitted as a handwritten separate file.
I made this code def computeosrmetricn:
Function to compute overlapping recursive calls, total recursive calls,
and the OSR metric based on matrix chain multiplication.
if n :
overlappingcalls
totalcalls
elif n :
overlappingcalls
totalcalls
else:
totalcalls n # Total recursive calls
overlappingcalls totalcalls n n # Overlapping calls using the provided formula
# OSR metric result: overlappingcalls totalcalls
osrmetric overlappingcalls totalcalls if totalcalls else
return overlappingcalls, totalcalls, osrmetric
def generatetablesize:
printf
Matrix Chain Size':Total Recursive Calls':
fOverlapping Recursive Calls':OSR Overlapping Subproblem Ratio:
print
for n in range size :
overlappingcalls, totalcalls, osrmetric computeosrmetricn
printfn:totalcalls:overlappingcalls:osrmetric:f
def main:
printOSR Metric Table Generator"
try:
tablesize intinputEnter the number of matrices size n:
if tablesize :
printPlease enter a positive integer for the table size."
return
generatetabletablesize
except ValueError:
printInvalid input. Please enter an integer for the table size."
if namemain:
main
but this code is not calculate overlapping recursivce calls truely I need help for calculate them correct. I guess correct ones something like
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
