Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

Students also viewed these Databases questions

Question

consider your role and influences as a researcher;

Answered: 1 week ago

Question

Experience with SharePoint and/or Microsoft Project desirable

Answered: 1 week ago

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago