Advertisement
Guest User

Untitled

a guest
May 28th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. def medyan(aList, k):
  2. while aList:
  3. kucukList = []
  4. buyukList = []
  5. count = 0
  6. pivot = aList[len(aList) // 2]
  7. for i in aList:
  8. if i < pivot:
  9. kucukList.append(i)
  10. elif i > pivot:
  11. buyukList.append(i)
  12. else:
  13. count += 1
  14. m = len(kucukList)
  15. if k >= m and k < m + count:
  16. return pivot
  17. if m > k:
  18. aList = kucukList
  19. else:
  20. k = k - m - count
  21. aList = buyukList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement