Solved

In the Following Code for the ArrayBag Class __Contains__ Method

Question 12

Multiple Choice

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:
< missing code >
Return False


A) right = midPoint + 1
B) left = midPoint - 1
C) right = left + 1
D) left = midPoint + 1

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions