Mathematics Behind Patience Sorting David Barra Capstone Advisor: Dr. King.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Lecture 15. Graph Algorithms
Great Theoretical Ideas in Computer Science
Shortest Vector In A Lattice is NP-Hard to approximate
Engineering Management Tidbits! © Washington State University James R. Holt, Ph.D., PE Professor Engineering.
Improved Algorithms for Inferring the Minimum Mosaic of a Set of Recombinants Yufeng Wu and Dan Gusfield UC Davis CPM 2007.
Longest Common Subsequence
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Lower bound: Decision tree and adversary argument
David Luebke 1 5/4/2015 CS 332: Algorithms Dynamic Programming Greedy Algorithms.
Lecture 16: DFS, DAG, and Strongly Connected Components Shang-Hua Teng.
3.3 The Characteristic function of the set  function from universal set to {0,1}  Definition 3.6: Let U be the universal set, and let A  U. The characteristic.
Recursion. n! (n factorial)  The number of ways n objects can be permuted (arranged).  For example, consider 3 things, A, B, and C.  3! = 6 1.ABC 2.ACB.
The Computation of Kostka Numbers and Littlewood-Richardson coefficients is #P-complete Hariharan Narayanan University of Chicago.
Refining Edits and Alignments Υλικό βασισμένο στο κεφάλαιο 12 του βιβλίου: Dan Gusfield, Algorithms on Strings, Trees and Sequences, Cambridge University.
The Simplex Algorithm An Algorithm for solving Linear Programming Problems.
Discrete Structures & Algorithms Counting Counting I: One-To-One Correspondence and Choice Trees.
Great Theoretical Ideas in Computer Science.
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
1 Maximal Independent Set. 2 Independent Set (IS): In a graph, any set of nodes that are not adjacent.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 15 Chances, Probabilities, and Odds 15.1Random Experiments and Sample.
Great Theoretical Ideas in Computer Science.
CSE 830: Design and Theory of Algorithms
Contents Introduction Related problems Constructions –Welch construction –Lempel construction –Golomb construction Special properties –Periodicity –Nonattacking.
MAE 552 – Heuristic Optimization Lecture 26 April 1, 2002 Topic:Branch and Bound.
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
App IV. Supplements to the Theory of Symmetric Groups Lemma IV.1: x p = p x p –1 Let { h } & { v } be horizontal & vertical permutations of Young tableaux.
Computer Algorithms Lecture 11 Sorting in Linear Time Ch. 8
The Marriage Problem Finding an Optimal Stopping Procedure.
Copyright © Cengage Learning. All rights reserved.
Ch. 8 & 9 – Linear Sorting and Order Statistics What do you trade for speed?
Randomized Algorithms - Treaps
Advanced Counting Techniques
Chapter 1 Probability and Distributions Math 6203 Fall 2009 Instructor: Ayona Chatterjee.
The Simplex algorithm.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 6 Counting and Probability Instructor: Hayk Melikyan Today we will review sections 6.4,
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
8. Linear Programming (Simplex Method) Objectives: 1.Simplex Method- Standard Maximum problem 2. (i) Greedy Rule (ii) Ratio Test (iii) Pivot Operation.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Blackjack: A Beatable Game Amber Guo Adapted from: David Parker Advisor: Dr. Wyels California Lutheran University ‘05.
Edge-disjoint induced subgraphs with given minimum degree Raphael Yuster 2012.
Dominance Since Player I is maximizing her security level, she prefers “large” payoffs. If one row is smaller (element- wise) than another,
Greedy Methods and Backtracking Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Chapter 7 Sampling Distributions Statistics for Business (Env) 1.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
LSP 120: Quantitative Reasoning and Technological Literacy Topic 1: Introduction to Quantitative Reasoning and Linear Models Lecture Notes 1.2 Prepared.
The Standard Normal Distribution Section Starter Weights of adult male Norwegian Elkhounds are N(42, 2) pounds. What weight would represent the.
COSC 3101NJ. Elder Announcements Midterm Exam: Fri Feb 27 CSE C –Two Blocks: 16:00-17:30 17:30-19:00 –The exam will be 1.5 hours in length. –You can attend.
CS Lecture 14 Powerful Tools     !. Build your toolbox of abstract structures and concepts. Know the capacities and limits of each tool.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 CS 140 Discrete Mathematics Combinatorics And Review Notes.
Linear Sorting. Comparison based sorting Any sorting algorithm which is based on comparing the input elements has a lower bound of Proof, since there.
Chance We will base on the frequency theory to study chances (or probability).
An Analysis of the n- Queens problem Saleem Karamali.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Alignment, Part II Vasileios Hatzivassiloglou University of Texas at Dallas.
Week 9 - Friday.  What did we talk about last time?  Permutations  Counting elements in sets  Brief introduction to combinations.
Discrete Structures for Computer Science
Great Theoretical Ideas In Computer Science
Discrete Mathematics for Computer Science
Enumerating Distances Using Spanners of Bounded Degree
Basic Counting.
Linear Time Sorting.
Presentation transcript:

Mathematics Behind Patience Sorting David Barra Capstone Advisor: Dr. King

What is Patience Sorting? Simple one person card game that is a practical method of sorting a real deck of cards Take a deck of cards labeled 1, 2, 3, …, n. The deck is shuffled and cards are turned up one at a time and dealt into piles on the table. At each stage of the game, we see the top card of each pile. A low card may be placed on a higher card, or may be put into a new pile to the right of the existing pile. The object of the game is to finish with as few piles as possible.

Example of Patience Sorting Permutation { }

Patience Sorting  Mathematics Random set of n cards can be represented by a permutation of n elements  An example for n = 10 is { } The optimal way to play patience sorting is to play using the Greedy Algorithm  The greedy algorithm says to always take the best move at that given time. It involves no look ahead strategy.  The greedy strategy is to always place a card on the leftmost possible pile, thus taking advantage of the first opportunity to place a card on top of another.

Patience Sorting  Mathematics When patience sorting is played using the Greedy strategy, the game will finish with ℓ(π) piles where ℓ(π) is the length of the longest increasing scattered subsequence of a permutation π. The longest increasing scattered subsequence is the longest subsequence of increasing terms, where intervening, non- increasing terms may be dropped.  Example π = { }. Longest increasing scattered subsequence is { } ℓ(π) = 4

Lemma 1 With deck π, patience sorting played using the greedy strategy ends with ℓ(π) piles. Furthermore, the game played with any legal strategy will end with at least ℓ(π) piles. Therefore, the greedy strategy is the optimal way to patience sort.

Proof: First we show that the number of piles is at least ℓ(π). If a subsequence of cards a 1 < a 2 < a 3 < … < a n appears in increasing order in a permutation of cards π, then under any legal strategy, each a i must be placed in some pile to the right of a i-1, because the top card of each pile can only decrease. In other words, no two cards in any increasing subsequence may end up in the same pile. Therefore, the final number of piles is at least the length of any increasing subsequence of π, and therefore, at least ℓ(π ).

Proof (cont.): Next we show that the number of piles is at most ℓ(π). We can use patience sorting to find an instance of an increasing subsequence thereby showing that we have at most ℓ(π) piles. Every time we place a card c in a pile i that is not the first pile, draw an arrow from c to the top card d of the previous pile. We know d<c and each arrow goes from a later card to an earlier card. The path of the arrows represents an increasing sequence in π. Therefore, the number of piles is at most ℓ(π). Since the number of piles is also at least ℓ(π), the number of piles is ℓ(π).

Playing with a 52 card deck To play with a deck of 52 cards, we need to linearly order the fifty cards.  The problem with 52 cards is that you may find yourself in the situation where, for example, a 3 is the top card of a pile and you are holding a 3. You need to know whether or not you can place that 3 on top of the other one. There can’t be any ties in patience sorting.  To solve the problem, order the suits. This orders the 52 cards such that you could order them 1, 2, 3,…, 52 in increasing order ….

Objective Compute the probability distribution of ℓ(π) for permutations of a given length n. In other words, what is the probability of getting ℓ(π) = 1, 2, 3,…, n for a permutation of length n? Three methods we investigate are: Patience Sorting with every possible permutation of length n Formula formed from the Schensted Correspondence  Mapping between a permutation and the combinatorical structures called standard Young tableaux Maple Programming

Compute P(L n = ℓ) by Patience Sorting Example for permutation of length 3 π# Piles {1, 2, 3}3 {1, 3, 2}2 {2, 1, 3}2 {2, 3, 1}2 {3, 1, 2}2 {3, 2, 1}1 Probability Distribution is: P(L 3 = 1) = 1 / 6 P(L 3 = 2) = 4 / 6 P(L 3 = 3) = 1 / 6

Standard Young Tableaux Along each row and down each column, we place the numbers 1…n in the cells in increasing order. This gives rise to a partition of a number n putting it in a standard Young tableau of shape λ, size n. The size n of a standard Young tableau is the number of cells it contains. Partition λ is the shape of the standard Young tableau of size n. A partition λ = (λ 1, λ 2,…, λ j ) of an integer n ≥ 1 is a sequence with λ 1 ≤ λ 2 ≤ … ≤ λ j, where λ i is the number of cells in row i. d λ is the number of standard Young tableaux of a given shape

Standard Young Tableaux The idea is to construct a pair of standard Young tableau from a permutation π by using the Schensted Column Insertion Algorithm. This forms a bijection between permutations and pairs of standard Young tableaux (P,Q). This is the Schensted Correspondence. For π = { } P Tableau Q Tableau

How to construct P tableau from permutation π π = { } 1.Place card into top row of tableau by patience sorting 2.If a card is covered, place it into the next row by patience sorting (thus bumping it)

P tableau for π = { }

Correspondence between Permutations of π cards and pairs of Standard Young Tableaux The length of the top row in the Young tableau associated with a permutation π is the length of the longest increasing scattered subsequence of π. Furthermore, the top row is the same as the top card of each pile in patience sorting. This is another way to calculate ℓ(π) P Tableau for π = { }. Longest increasing subsequence is { }

How does everything relate to each other? π  P tableauQ tableau Length of top row of tableaux Patient Sort # Piles ℓ(π) {1, 2, 3}  333 {1, 3, 2}  222 {2, 1, 3}  222 {2, 3, 1}  222 {3, 1, 2}  222 {3, 2, 1}  111

Correspondence between permutation of π cards and pairs of standard Young tableaux This gives a formula for the probability P(L n = ℓ) that the longest increasing scattered subsequence of a random permutation of {1, 2, …, n) has length ℓ.

Applying the Formula for P(L 3 = ℓ) P(L 3 = 1) = (1 / 3!) ∙ 1 2 = 1 / 6 P(L 3 = 2) = (1 / 3!) ∙ 2 2 = 4 / 6 P(L 3 = 3) = (1 / 3!) ∙ 1 2 = 1 / 6 d (3) = 1 d (2,1) = 2 d (1,1,1) = Remember: d λ is the number of standard Young tableaux of a given shape

Programming Maple to Patience Sort By David Barra and Dr. Wyels Program Maple to Patience Sort using patience sorting as the algorithm for computing ℓ(π) Program Maple to collect the data for a large number of trials and find the P(L n = ℓ) for a given n

Acknowledgements Dr. King Dr. Fogel Dr. Wyels David Parker Lucas Lembrick

Sources Diaconis, Perci. “Longest Increasing Subsequences: From Patience Sorting to the Baik-Deift-Johansson Theorem.” Stanford University, D. Stanton and D. White. Constructive Combinatorics. Undergraduate Textbooks in Mathematics. Springer and Verlag, Eric. W Weisstein. “Young Tableau.” From Mathworld—A Wolfram Web Resource.

The Hook Formula (another way to calculate d λ ) The hook length of a cell h c is the number of cells in the set consisting of the cells to the right of c in its row, the cells below c in its column, and c itself. The number of standard Young tableau d λ of a given shape λ, is given by the Hook Formula.  d λ = n! / (Π c h c )