## DMPG '17 B4 - Bad Sort

View as PDF

Points: 7
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Roger is teaching his CS club how to sort! This algorithm looks like this:

function sort(A[0 .. N - 1]):
if A is not empty:
pivot <- A[N/2]
lesser <- []
equal <- []
greater <- []
for each a in A:
if a < pivot:
append a to lesser
if a = pivot:
append a to equal
if a > pivot:
append a to greater
sort(lesser)
sort(greater)
A <- lesser + equal + greater


However, you think that Roger is inferior to Kirito, and that his sort has a devastating flaw! Can you generate a worst case?

#### Input Specification

There is no input.

#### Output Specification

Print integers, each on a newline, representing a worst-case scenario for the sorting algorithm.