Question: Q 1 . Given the following pseudocode of a method named magic: integer magic ( integer a , integer b ) If ( b equal

Q1.Given the following pseudocode of a method named magic:
integer magic (integer a, integer b)
If ( b equal to 0)
return a
else
return magic ( b, a modulo b)
1)What is the running time of the method?
2)How many calls will be performed for this method when a =70 and b =25
Q2.Given the following pseudocode of a method named shock:
Integer shock (integer n)
If ( n equal to 0)
Return 0
If ( n equal to 1)
Return 1
else
Return shock ( n -2)+ shock ( n 1)
1)What is the running time of the method?
2)How many calls will be performed for this method when n =7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!