Question
Write a program that uses linear recursion to generate a copy of an original collection in which the copy contains duplicates of every item in
Write a program that uses linear recursion to generate a copy of an original collection in which the copy contains duplicates of every item in the original collection. Include search capability to determine if an item is in a collection. Include sort capability to sort a collection.
Program specification: Using linear recursion, implement a function that takes a list as user-supplied runtime input and returns a copy of it in which every list item has been duplicated. Given an empty list the function returns the base case of an empty list. Using Python's built-in search methods determine if a target is in the list and sort a list.
Testing requirements: Import solution module into a decoupled test driver. Demonstrate the following:
Error Checking: Validate user list input; not to advance until valid data is entered.
Test Run Requirements: Provide 5 test cases including the default base case of an empty list, duplicating 2 original collections, determine if an item is in a collection, and provide a sorted display of a collection. Provide a commented out copy of the test demonstration at the bottom of the test driver source file.
Here are some other tips and requirements: 1. Create user defined functions 2. Use data passing and return statements. Here is a sample partial run: [ ] [' copper', 'copper'] ['nicke1', 'nickel', 'copper', 'copper'] nickel in the list sorted list: ['copper', 'copper', 'nickel', 'nickel']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