Question
PLEASE READ ENTIRE QUESTION The code is below. The idea is to step through both lists one element at a time. Compare two elements, one
PLEASE READ ENTIRE QUESTION
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): ''' 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 < len(listA) - 1 and indexB < len(listB) - 1: # step through the lists one element at a time # put the smaller element in the result if listA[indexA] < listB[indexB]: result.append(listA[indexA]) indexA = indexA + 1 else: result.append(listA[indexA]) indexB = indexB + 1 # add the remaining elements if indexA < len(listA): result.extend(listA[indexA:]) return result
here are the questions 1. Write white-box and black-box tests for the function merge(). Make sure you have at least 3 black-box tests, and 3 white-box tests, as a minimum. More tests may be useful. 2. Implement your test cases in a document. You can use either plain if-statements or a list-of-dictionaries to implement your test driver
3. Run your tests. Try to deduce the problems with the merge() function from the output of your testing. Then fix the errors in the function, so that your test driver does not indicate any faults and we write the corrected function
NOTE: The most important parts of the question are to FIND the specific errors in the code, EXPLAIN why those are errors AND explain how you would go about fixing them. Do not neglect any of these parts.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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