Question 34 In the code for the add method in the implementation of a heap, what is the missing code? def add(self, item
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Question 34 In the code for the add method in the implementation of a heap, what is the missing code? def add(self, item
Question 34 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) curPoslen (self.heap) - 1 while curPos > 0: parent (curPos - 1) 7/2 parentItem-self-heap [parent] if parentItem <- item: missing code> else: self.heap [curPos] - self.heap[parent] self.heap [parent] sten curPos-parent curPos += 1 Obreak O self heap[curPos] = item parent curpos 1 pts
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!