Question
WRITE SOLUTION CODE IN Python 3 for the following question: Starter Code: def merge(listA, listB): ''' Given 2 lists whose elements are in increasing order,
WRITE SOLUTION CODE IN Python 3 for the following question:
Starter Code:
def merge(listA, listB): ''' Given 2 lists whose elements are in increasing order, merge them into one list of elements in increasing order :param listA: a list in increasing order :param listB: a list in increasing order :return: a list with all elements in increasing order ''' result = [] indexA = 0 indexB = 0
while indexA
# add the remaining elements if indexA
return result
Question:
In starter code, you'll find the function
merge(): Given 2 lists whose elements are in increasing order, merge them into one list of elements in increasing order.
The code is below. The idea is to step through both lists one element at a time. Compare two elements,
one from each list, and put the smaller into the merged list. If you reach the end of either list, add the rest
of the other list to the end of the merged result. (See attached photo)
This function contains errors. Your task will be to nd the errors using testing. Youll hand in an explanation of what the errors are, and how you xed them, but you will not hand in the corrected code.
1. Write white-box and black-box tests for the function merge(). You should do this without Python, either on paper, or in a simple document. Dont worry about running your tests until you have thought about which tests you want. Make sure you have at least 3 black-box tests, and 3 white-box tests, as a minimum. More tests may be useful.
2. Implementyourtestcasesinadocumentnameda8q3_testing.py.Youcanuseeitherplainif-statements (as demonstrated in readings 15.2.4) or a list-of-dictionaries to implement your test driver (as demon- strated in class during chapter 15 exercise 3).
3. Run your tests, and copy/paste the console output to a document named a8q3_output.txt. The console output you hand in should come from the program before you try to x it!
4. Try to deduce the problems with the merge() function from the output of your testing. Then x the errors in the function, so that your test driver does not indicate any faults.
5. In the document a8q3_output.txt, describe the error(s) you found, and how you xed it (them). You do not need to write a lot; a sentence or two for each error is all we want. Write your explanation as if you are explaining the error to a colleague of yours who wrote the function.
What to Hand In
A document containing your testing code as described above.
A document with the output of your testing copy/pasted into it, and the explanations of the errors you found.
Evaluation
Your test-driver for merge() contains at least 6 test cases. The output of your test driver reveals faults in the given function. You correctly identifed four errors in merge(), and explained brie y how you xed them.
The code is below. The idea is to step through both lists one element at a time. Compare two elements one from each list, and put the smaller into the merged list. If you reach the end of either list, add the rest of the other list to the end of the merged result. def merge(listA, listB): 3 Given 2 lists whose elements are in increasing order, merge them into one list of elements in increasing orde:r :param listA: a list in increasing order :param listB: a list in increasing order :return: a list with all elements in increasing order 3 result = [] indexA = 0 indexB = 0 while indexAStep 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