This preview shows page 1. Sign up to view the full content.
Unformatted text preview: e that fits.
Observation. At any stage during greedy algorithm, top cards of piles
increase from left to right. first card
to deal first card
to deal top cards
3 4 PatienceLIS: weak duality PatienceLIS: strong duality Weak duality. In any legal game of patience, the number of piles ≥ Theorem. [Hammersley 1972] Min number of piles = max length of an IS; length of any increasing subsequence. moreover greedy algorithm finds both. Pf. Pf. Each card maintains a pointer to top card in previous pile. ・
・Any increasing sequence can use at most one card from each pile. ▪ at time of insertion ・Follow pointers to obtain IS whose length equals the number of piles.
・By weak duality, both are optimal. ▪ Cards within a pile form a decreasing subsequence. decreasing
subsequence increasing subsequence
5 6 Greedy algorithm: implementation Patience sorting Theorem. The greedy algorithm can be implemented in O(n l...
View
Full
Document
This document was uploaded on 02/11/2014.
 Spring '09

Click to edit the document details