

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Prim's algorithm for determining the minimum spanning tree of a graph. It explains the greedy criteria used by the algorithm and provides an incorrect code example. The document also suggests using priorityqueueentry objects and discusses the comparison of keys and values in the __lt__, __gt__, and __eq__ methods. Lastly, it provides an incomplete implementation of the __contains__ and decreasekey methods for the binheap class.
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


a
b
d
h
e
f
g
c
class PriorityQueueEntry: def init(self,x,y): self.key = x self.val = y
def getKey(self): return self.key
def getValue(self): return self.val
def setValue(self, newValue): self.val = newValue
def lt(self,other): return self.key < other.key
def gt(self,other): return self.key > other.key
def eq(self, other): return self.val == other.val
def hash(self): return self.key