LongestIncreasingSubsequence-2x2

# Observation at any stage during greedy algorithm top

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

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 Patience-LIS: weak duality Patience-LIS: 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.

Ask a homework question - tutors are online