in all values from either lista or listb being copied to the newlist and all but one value from the other for total of iterations thenone of the next two loops will execute single iteration in order to copy the last value to the newlist the minimum number of iterations performed by the first loop occurs when all values from one list are copied to the newlist and none from the other if the first loop copies the entire contents of lista to the newlistit will require iterations followed by iterations of the third loop to copy the values from listb if the first loop copies the entire contents of listb to the newlistit will require iterations followed by iterations of the second loop to copy the values from lista in both casesthe three loops are executed for combined total of iterations since the statements performed by each of the three loops all require constant timemerging two lists can be done in (ntime the set adt revisited the implementation of the set adt using list was quick and rather simplebut several of the operations require quadratic time in the worst case this inefficiency is due to the linear search used to find an element in the unsorted list that is required by several of the operations we saw earlier in the the efficiency of the search operation can be improved by using the binary search algorithm to use the binary search with the set adtthe list of elements must be in sorted order and that order must be maintained the definition of the set adthoweverindicates the elements have no particular ordering while this is trueit does not preclude us from storing the elements in sorted order it only means there is no requirement that the items must be stored in particular order sorted list implementation in using the binary search algorithm to improve the efficiency of the set operationsthe list cannot be sorted each time new element is added because it would increase the time-complexity of the add(operation for examplesuppose we used one of the sorting algorithms presented earlier in the to sort the list after each element is added since those algorithms require ( time in the worst casethe add(operation would then also require quadratic time insteadthe sorted order must be maintained when new elements are added by inserting each into its proper position partial implementation of the set adt using sorted list and the binary search algorithm is provided in listing there are no changes needed in the constructor or the len methodbut some changes are needed in the remaining methods