Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def medyan(aList, k):
- while aList:
- kucukList = []
- buyukList = []
- count = 0
- pivot = aList[len(aList) // 2]
- for i in aList:
- if i < pivot:
- kucukList.append(i)
- elif i > pivot:
- buyukList.append(i)
- else:
- count += 1
- m = len(kucukList)
- if k >= m and k < m + count:
- return pivot
- if m > k:
- aList = kucukList
- else:
- k = k - m - count
- aList = buyukList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement