You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def quick_sort(array, start, end):
if start >= end:
return
pivot = start
left = start + 1
right = end
while (left <= right):
while (array[left] <= array[pivot] and left <= end):
left += 1
while (array[right] >= array[pivot] and right > start):
right -= 1
if (left > right):
array[right], array[pivot] = array[pivot], array[right]
else:
array[left], array[right] = array[right], array[left]
quick_sort(array, start, right - 1)
quick_sort(array, right + 1, end)
quick_sort(array, 0, len(array)-1)
print(array)
원본이랑 비교할 때 left<=end and array[left] <= array[pivot] 랑 순서만 다른 것 같은데 오류가 발생하는데 왜인지 모르겠습니다 ㅜ
A and B 랑 B and A는 완전히 동일한 명제 아닌가요?
The text was updated successfully, but these errors were encountered:
array = [5, 7, 9, 0, 3, 1, 6, 2, 4, 8]
def quick_sort(array, start, end):
if start >= end:
return
pivot = start
left = start + 1
right = end
while (left <= right):
while (array[left] <= array[pivot] and left <= end):
left += 1
while (array[right] >= array[pivot] and right > start):
right -= 1
if (left > right):
array[right], array[pivot] = array[pivot], array[right]
else:
array[left], array[right] = array[right], array[left]
quick_sort(array, start, right - 1)
quick_sort(array, right + 1, end)
quick_sort(array, 0, len(array)-1)
print(array)
원본이랑 비교할 때 left<=end and array[left] <= array[pivot] 랑 순서만 다른 것 같은데 오류가 발생하는데 왜인지 모르겠습니다 ㅜ
A and B 랑 B and A는 완전히 동일한 명제 아닌가요?
The text was updated successfully, but these errors were encountered: