MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / insert

Method insert

data_structures/heap/heap.py:68–76  ·  view source on GitHub ↗
(self,data)

Source from the content-addressed store, hash-verified

66 self.currsize = size
67
68 def insert(self,data): #This function is used to insert data in the heap.
69 self.h.append(data)
70 curr = self.currsize
71 self.currsize+=1
72 while self.h[curr] > self.h[curr/2]:
73 temp = self.h[curr/2]
74 self.h[curr/2] = self.h[curr]
75 self.h[curr] = temp
76 curr = curr/2
77
78 def display(self): #This function is used to print the heap.
79 print(self.h)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected