Lesson 24: Generating Permutations - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Lesson 24: Generating Permutations

Description:

... a set can be generated in lexicographic order. Example: 321546 precedes 321456 ... Place the following permutations of 1, 2, 3, 4, 5, 6 in lexicographic order: ... – PowerPoint PPT presentation

Number of Views:286
Avg rating:3.0/5.0
Slides: 12
Provided by: jwi6
Category:

less

Transcript and Presenter's Notes

Title: Lesson 24: Generating Permutations


1
Lesson 24 Generating Permutations
  • Objectives
  • Generate all permutations of a set
  • Generate all subsets of a set
  • Generate all r combinations of a set
  • Outline
  • Permutations of a set
  • Subsets
  • HW due May 4

2
Generating Permutations
  • Given a particular set, we wish to generate all
    possible permutations in an orderly way
  • This can be used to check solutions to problems
    involving sets
  • Example Traveling salesman
  • Every set can has a one-to-one correspondence
    with the set 1, 2, 3, , n

3
Permutations
  • Permutations of a set can be generated in
    lexicographic order.
  • Example 321546 precedes 321456

4
Example 1
  • Place the following permutations of 1, 2, 3, 4,
    5, 6 in lexicographic order

5
Generating permutations
  • Find the least significant sequence of descending
    digits
  • 7625341
  • Swap the preceding number with the next greatest
    number in the descending sequence
  • Put the rest of the numbers in ascending sequence

6
Example 2
  • 362541
  • 263541
  • 264531 (next 5 terms)

7
Problem 1
  • Find the next number in the permutation sequence
    following 17386542

8
Example 3
  • Find the permutation of 1, 2, 3, 4, 5, 6
    immediately before 261345 in lexicographic order.

9
Example 4
  • If the permutations of 1,2,3,4,5,6 are put in
    lexicographic order, with 123456 in position 1,
    123465 in position 2, etc., find the permutation
    in position 362.

10
Example 5
  • If the permutations of 1,2,3,4,5 are put in
    lexicographic order, in what position is the
    permutation 41253?

11
Subsets
  • To generate all subsets of a set, express
    membership by a 1 in a bit string.
Write a Comment
User Comments (0)
About PowerShow.com