This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
How to stop the recursion
Post Body
Hello, I am making a visualization program in python that implements various sorting algorithms. I’ve gotten almost all of the implemented but the quicksort algorithm is being a bit of a pain. It sorts perfectly fine and visualizes the algorithm perfectly until but I have no way of making the function stop its recursion. It’s really stumping me and any help would be greatly appreciated.
Here is the code:
START OF CODE
def quick_sort(array):
if len(array) < 2:
return array
less, same, more = [],[],[]
start_point =
array[random.randint(0,len(array)-1]
for point in array:
if point < start_point:
less.append(point)
elif point == start_point:
same.append(point)
elif point > start_point:
more.append(point)
array = less same more
window.blit(image, (0, 0))
show_bars(array, color, x, y, width)
pygame.time.delay(50)
pygame.display.update()
return quick_sort(array)
END OF CODE
Author
Account Strength
80%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
26
Link Karma
2
Comment Karma
24
Profile updated: 3 days ago
Posts updated: 4 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...