Advertisement
Guest User

Untitled

a guest
May 1st, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class heap:
  2. def __init__(self):
  3. self.current = 0
  4. self.dizi = [0]
  5. def insert(self,x):
  6. self.dizi.append(x)
  7. self.current = self.current +1
  8. i = self.current
  9. while(i>0):
  10. if(self.dizi[i]<self.dizi[int(i/2)]):
  11. temp = self.dizi[i]
  12. self.dizi[i] = self.dizi[int(i/2)]
  13. self.dizi[int(i/2)] = temp
  14. i = int(i/2)
  15. else:
  16. break
  17. yaprak = heap()
  18. yaprak.insert(50)
  19. yaprak.insert(60)
  20. yaprak.insert(30)
  21. yaprak.insert(90)
  22. yaprak.insert(100)
  23. print(yaprak.dizi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement