Page 1 of 1

Question 34 In the code for the add method in the implementation of a heap, what is the missing code? def add(self, item

Posted: Thu May 05, 2022 2:01 pm
by answerhappygod
Question 34 In The Code For The Add Method In The Implementation Of A Heap What Is The Missing Code Def Add Self Item 1
Question 34 In The Code For The Add Method In The Implementation Of A Heap What Is The Missing Code Def Add Self Item 1 (54.5 KiB) Viewed 44 times
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