Answered step by step
Verified Expert Solution
Question
1 Approved Answer
01020304050607080910Magic(a1,,an:anarrayofnpositiveintegers)if(n=1)returna1elseif(n=2)returna1+a2elseif(n=3)returna1+a2+a3elsep=n/3q=2n/3rv=Magic(a1,,ap)+Magic(aq+1,,an)constanttimetodivideanarrayrv=rv+Magic(ap+1,,aq)returnrv The running time of Magic is (X) where X is .... (a) logn
01020304050607080910Magic(a1,,an:anarrayofnpositiveintegers)if(n=1)returna1elseif(n=2)returna1+a2elseif(n=3)returna1+a2+a3elsep=n/3q=2n/3rv=Magic(a1,,ap)+Magic(aq+1,,an)\\constanttimetodivideanarrayrv=rv+Magic(ap+1,,aq)returnrv The running time of Magic is (X) where X is .... (a) logn
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started