short-circuit evaluation most programming languages use shortcircuit evaluation when testing compound logical expressions if the result of the compound expression is known after evaluating the first componentthe evaluation ends and returns the result for examplein evaluating the logical expression and is falsethen there is no need to continue the evaluation of the second component since the overall expression must be false note basic operations performing binary search to locate an element in the sorted list or to find the position where an element belongs in the sorted list is needed in several methods instead of reimplementing the operation each timewe implement the modified version of the binary search algorithm from listing in the findposition(helper method the helper method does not detect nor distinguish between unique and duplicate values it only returns the index where the element is located within the list or where it should be placed if it were added to the list thuscare must be taken when implementing the various methods to check for the existence of an element when necessary the contains method is easily implemented using findposition(the index value returned by the helper method indicates the location where the element should be within the sorted listbut it says nothing about the actual existence of the element to determine if the element is in the setwe can compare the element at the ndx position within the list to the target element note the inclusion of the condition ndx len(selfwithin the compound expression this is needed since the value returned by findposition(can be one larger than the number of items in the listwhich occurs when the target should be located at the end of the list if this value were directly used in examining the contents of the list without making sure it was in rangean out-of-range exception could be raised the contains method has worst case time of (log nsince it uses the binary search to locate the given element within the sorted list to implement the add(methodwe must first determine if the element is unique since set cannot contain duplicate values this is done with the use of the in operatorwhich automatically calls the contains operator method if the element is not already member of the setthe insert(method is called to insert the new element in its proper position within the ordered list even though the contains method has better time-complexity when using sorted list and the binary searchthe add(operation still requires (ntimethe proof of which is left as an exercise the remove(method requires that the target element must be member of the set to verify this preconditionan assertion is made using the in operator after whichthe findposition(helper method is called to obtain the location of the elementwhich can then be used with the pop(list method to remove the element from the underlying sorted list like the add operationthe remove(method still has worst case time of ( )the proof of which is left as an exercise