the status of stable quicksort
play

The Status of Stable Quicksort Jrgen Villadsen Informatics and - PowerPoint PPT Presentation

The Status of Stable Quicksort Jrgen Villadsen Informatics and Mathematical Modelling Technical University of Denmark 3rd STL Workshop DIKU, Denmark, 17 December 2001 Introduction A sorting method is said to be stable if it preserves the


  1. The Status of Stable Quicksort Jørgen Villadsen Informatics and Mathematical Modelling Technical University of Denmark 3rd STL Workshop DIKU, Denmark, 17 December 2001

  2. Introduction A sorting method is said to be stable if it preserves the relative order of items with duplicate keys Stability can always be forced by appending an index to each key before sorting Mergesort is stable with straightforward implementation of the merging using an extra array Heapsort is not stable, but in-place Quicksort is — normally — not stable, but (as good as) in-place Jyrki Katajainen & Tomi Pasanen Stable Minimum Space Partitioning in Linear Time BIT 32 (1992) 580–585 Jyrki Katajainen & Jesper Larsson Träff On Stable Quicksort Unfinished draft... 1

  3. Stable Quicksort Using an Extra Array Partition into 3 parts: • < at beginning of original array • = at beginning of extra array • > at end of extra array — in reverse order Copy of = Quicksort and Retro-Quicksort of < and > respectively Just one Partition Also Retro-Copy — and extra Copy or just Reversing... 2

  4. Stable Quicksort With O ( √ n ) Extra Space Use 3 buckets of size √ n : • < items • = items • > items When a bucket gets full, move the items back to original array Use a stable variant of Selectionsort afterward on the blocks Selectionsort makes the fewest moves possible for a sorting — O ( n ) — but is O ( n 2 ) , which is ok! Finally also in-place versions... 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend