Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quicksort implementation issue - Java
#7
1. Maybe you should paste their code here then.

2.3. The whole point is that quicksort is only fast when two partitions are roughly the same size. When you have a large number of duplicate values one partition will be much larger than the other, causing more recursive calls. In the case of the entire array being duplicates, it becomes the same as selection sort, i.e. O(n^2). You should be counting the number of comparisons there, not number of swaps.

When people discuss sorting algorithms, they generally assume there are no duplicate values.
Reply


Messages In This Thread
Quicksort implementation issue - Java - by Russt - 2012-04-29, 06:21 PM
Quicksort implementation issue - Java - by Corn - 2012-05-02, 03:36 PM
Quicksort implementation issue - Java - by happylight - 2012-05-03, 10:28 PM
Quicksort implementation issue - Java - by nRxUs - 2012-05-04, 01:54 AM
Quicksort implementation issue - Java - by Spaz - 2012-05-04, 07:27 AM
Quicksort implementation issue - Java - by Corn - 2012-05-04, 07:38 AM
Quicksort implementation issue - Java - by Russt - 2012-05-05, 03:55 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)