• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Quicksort doesnt fully sort an array

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You are doing initialization and incrementing index at every value of i.. May be problem is here..
 
Greenhorn
Posts: 7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic