javascript - Is there a black box method to detect if a sorting algorithm is stable? -


in javascript (somewhat applicable elsewhere), don't know target implementation code running on, there way feature detect if underlying sorting algorithm (of array.sort) stable or not, knowing follows the specification?

i find 2 tests in webkit (1) (2), how reliable tests? (could check done pcp?) i'm looking solution mathematically sound.

this tricky problem, since more advanced sorting algorithm can change subalgorithms depending on length of source array (like timsort). i've been confused since every test i've run has shown google chrome's sort stable, documentation i've seen has said it's unstable (the source tell why).

(typically, use this strategy make sorts stable; has small noticable performance impact)

source code sorting in various implementations:

black-box testing can not used determine program satisfies criterion unless can test possible inputs relevant criterion. black box free have lookup table maps inputs outputs (see pentium fdiv bug real-world lookup table bug) cannot sure tests preclude possibility of other input triggering violation.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -