Should I shuffle the list before quicksort in OCaml? -


it suggested shuffle array before quicksort it.

however, if want quicksort list, shuffling list first take o(nlogn), example, assign random key each item in list , mergesort (key, item) list.

then my question is:

if have spend o(nlogn) shuffle list first, what's point of implementing quicksort list in ocaml?

we should use mergesort directly, right?

in op's question:

however, if want quicksort list, shuffling list first take o(nlogn)

i think random shuffling costs o(n) time if first convert list array , use fisher–yates shuffle, algorithm used in python's random.shuffle.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -