Question
Analyze function2 with respect to the length of the mystring. Hint, You will need to set up two mathematical functions for operator counting. one for
Analyze function2 with respect to the length of the mystring. Hint, You will need to set up two mathematical functions for operator counting. one for function2 and the other for recursive_function2
def recursive_function2(mystring,a, b): if(a >= b ): return True else: if(mystring[a] != mystring[b]): return False else: return recursive_function2(mystring,a+1,b-1) def function2(mystring): return recursive_function2(mystring, 0,len(mystring)-1)
function 3 :
Analyze the following function with respect to the number
def function3(value, number): if (number == 0): return 1 elif (number == 1): return value else: half = number // 2 result = function3(value, half) if (number % 2 == 0): return result * result else: return value * result * result
CAN YOU DO BOTH THE FUNCTIONS USING THESE 5 STEPS
Step 1: Establish variables and functions (mathematical ones):
Step 2: Count your operations
Step 3: Establish the Mathematical Expression for T(n)
Step 4: Simplify your Equation
Step 5: State your final result.
Step 3: Establish the Mathematical Expression for T(n)
Step 4: Simplify your Equation
Step 5: State your final result.
CAN YOU ALSO DO THE MATHEMATICAL EXPRESSION FOR T(n) BESIDE THE LINES OF CODE
LASTLY THIS IS PYTHON PROGRAMMING.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Lets analyze both function2 and function3 in terms of their time complexity using the five steps you mentioned Function 2 Analysis Step 1 Establish va...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