171k views
2 votes
For two arrays A and B that are already in ascending order, write a program to mingle them into a new array ordered C evenly, the size of C is varied, depending on the values of A and B: the even-indexed (the index starts from 0) elements come from A while odd-indexed elements are from B. For instance, if A is (1,4, 10,12): B is 12.3,10, 11) then the new array C is (1, 2,4,10,12). If a black-box test approach will be used, how many test cases should you design?

1 Answer

4 votes

Answer:

def generate_list(listA, listB):

listC = []

for item in listA[0::2]:

listC.append(item)

for items in listB[1::2]:

listC.append(items)

return sorted(listC)

Step-by-step explanation:

The python program defines a function called generate_list that accepts two list arguments. The return list is the combined list values of both input lists with the even index value from the first list and the odd index value from the second list.

User Max Bileschi
by
4.9k points