• Post Reply Bookmark Topic Watch Topic
  • New Topic

Quicksort doesnt fully sort an array  RSS feed

 
Michael Doe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am having a problem sorting an array using quicksort. When I run the quick sort on my array the output is almost sorted(see below). I would love some help or feedback.


I feel like the problem lies in the partitioning function, but I am not to sure.


Thanks in advance!







Output: Before Swap:
5 23 69 55 448 3 78
After Swap:
5 69 23 55 448 3 78

Original Array
5 69 23 55 448 3 78
Sorted Array
5 23 55 69 78 3 448
BUILD SUCCESSFUL (total time: 0 seconds)
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You are doing initialization and incrementing index at every value of i.. May be problem is here..
 
T Tak
Greenhorn
Posts: 7
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have recently written an article on how to quicksort a list in java. I hope this will help you,
Quicksort in java
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!