Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

168p 6-4 조건 순서를 다르게했더니 오류가 발생해요 #182

Open
summerlight636 opened this issue Apr 22, 2022 · 0 comments
Open

Comments

@summerlight636
Copy link

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는 완전히 동일한 명제 아닌가요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant