In the following code for the ArrayBag class __contains__ method, what is the missing code?
def __contains__(self, item): left = 0 right = len(self) - 1 while left <= right: midPoint = (left + right) // 2 if self.items[midPoint] == item: return True elif self.items[midPoint] > item: right = midPoint - 1 else: return False
A. right = midPoint + 1
B. left = midPoint - 1
C. right = left + 1
D. left = midPoint + 1
Answer: D
Computer Science & Information Technology
You might also like to view...
Which of the following describes the act of ensuring that a program solves the intended problem in all cases?
a) establishing the requirements b) testing c) preliminary practice coding d) implementing the design e) creating a design
Computer Science & Information Technology
By convention, what is the name of serial port 0 on a router?
a. S0 b. System 0 c. Serial interface 0 d. Serial AUI 0
Computer Science & Information Technology
The comment indicator appears on a slide in ________ view
Fill in the blank(s) with correct word
Computer Science & Information Technology
A PowerPoint presentation can be saved as a Web page and posted to the World Wide Web
Indicate whether the statement is true or false
Computer Science & Information Technology