• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic