Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[50 points] Design a recursive algorithm that will display whether it is possible to choose two integers from a list of integers such that the
[50 points] Design a recursive algorithm that will display whether it is possible to choose two integers from a list of integers such that the difference between the two equals a given value. Hint: You may wish to invoke another algorithm, (i.e., function), that accepts more parameters that perform the recursion. Submit a python function is_diff_two(values, diff) that take a list and the desired difference as a non-negative integer and returns true or false.
Examples:
is_diff_two([2, 4, 8], 4) # returns True is_diff_two([1, 2, 4, 8, 1], 7) # returns True is_diff_two([2, 4, 4, 8], 7) # returns False is_diff_two([], 7) # returns False is_diff_two([-1,-3,5,8,10],11) #returns True
Restrictions
- The only functions you may use are: print, str, int, float, bool, len, list, range, abs, round, and pow.
- Note that you may not use list slicing (AKA colons in your indices).
- We will not deduct for the use of str(), but you do not actually need it.
- Do not import libraries.
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