-1

i would like to know what kind of sample data i can insert to make the quick-sort go from normal to worst case performance. Can i use the following data 1,2,3,1,4,5,1,8,1,2 to make the quick-sort go haywire. The net explains the theory but does not shows how it can be done. I would like to know what kind of data can i use for testing to show quick-sort worst case performance.

I am a naive implemented quicksort alogorithm in c++. My only problem is what kind of data can use to show it.

M.A
  • 1,073
  • 2
  • 15
  • 21
  • 2
    Does searching for "quicksort worst case" [turn up](http://stackoverflow.com/a/2415215/41655) [with nothing](http://stackoverflow.com/a/4019832/41655)? Also which the worst case is for your implementation depends on how you choose the pivot, so this isn't answerable without code. – millimoose Jul 27 '13 at 16:36

1 Answers1

2

You can try to read the paper "A Killer Adversary for Quicksort" by M. D. McIlroy, 1. It is a very readable paper, and just 4 pages. It actually contains C code for an implementation that will cause qsort to behave badly.

user515430
  • 3,341
  • 2
  • 17
  • 13