In the code for the add method in the implementation of a heap, what is the missing code?
def add(self, item): self.size += 1 self.heap.append(item) curPos = len(self.heap) - 1 while curPos > 0: parent = (curPos - 1) // 2 parentItem = self.heap[parent] if parentItem <= item: else: self.heap[curPos] = self.heap[parent] self.heap[parent] = item curPos = parent
A. curPos += 1
B. break
C. self.heap[curPos] = item
D. parent = curpos
Answer: B
You might also like to view...
Which syntax imports all static members of class Math?
a. import java.lang.Math.*. b. import static java.lang.Math.*. c. import static java.lang.Math. d. None of the above.
____________________ links specify a path from the current page.
Fill in the blank(s) with the appropriate word(s).
Katie is working in a customer table and needs to know if any customers are located in Texas. In order to locate this information, she would:
A) create a report. B) create a form. C) create a query. D) create a new table.
A legacy device does not represent a security threat because it is based on well-tested hardware and operating systems
Indicate whether the statement is true or false