Generating Permutations and Combinations “Traveling Salesman Problem” – A salesman must visit 6 cities; what’s the best order in which to visit them? Assume.

Slides:



Advertisements
Similar presentations
5.3 Permutations and Combinations
Advertisements

1 Counting Techniques: Possibility Trees, Multiplication Rule, Permutations.
Counting Chapter 6 With Question/Answer Animations.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata are like Turing Machines with a restriction: The working space of the tape is the space of the.
Lec 13 Oct 17 cell arrays structures advanced recursive programs.
Combinations We should use permutation where order matters
Permutations. Motivation Shuffling – Games – Music players Brute-force algorithms.
Sequence A list of objects arranged in a particular order.
Homework page 102 questions 1, 4, and 10 page 106 questions 4 and 5 page 111 question 1 page 119 question 9.
1 More Counting Techniques Possibility trees Multiplication rule Permutations Combinations.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every.
Be prepared to take notes when the bell rings.
2.1 Integers & Absolute Value 2.2 Adding Integers.
1.7 Arrays academy.zariba.com 1. Lecture Content 1.Basic Operations with Arrays 2.Console Input & Output of Arrays 3.Iterating Over Arrays 4.List 5.Cloning.
How many ways are there to pass through city A where the arrows represent one-way streets? Answer: mn ways The counting principal: Suppose two experiments.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Computer Implementation of Genetic Algorithm
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Generalized Permutations and Combinations
Combinatorial Algorithms Reference Text: Kreher and Stinson.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
MA/CSSE 473 Day 14 Permutations wrap-up Subset generation (Horner’s method)
MA/CSSE 473 Day 18 Permutations by lexicographic order number.
5.6 Generating Permutations and Combinations Generating Permutations Many different algorithms have been developed to generate the n! permutations of this.
FUNCTIONS Definition Let A = {1, 2, 3,..., n}, and f : A → A be a bijective function; then f is called a permutation on n. QUESTION: for a set with N elements.
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
FUNCTIONS.
A Universal Turing Machine
Evolution Programs (insert catchy subtitle here).
Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis
Genetic Algorithms. 2 Overview Introduction To Genetic Algorithms (GAs) GA Operators and Parameters Genetic Algorithms To Solve The Traveling Salesman.
Math 3121 Abstract Algebra I Lecture 5 Finish Sections 6 + Review: Cyclic Groups, Review.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Equivalence Relations. Partial Ordering Relations 1.
Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 4 Counting.
Combinatorics University of Akron Programming Team 9/23/2011.
Section 6.6 Scale Drawings
Section 3.2: Sequences and Summations. Def: A sequence is a function from a subset of the set of integers (usually the set of natural numbers) to a set.
5.5 Generalized Permutations and Combinations
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
1 Chapter 4 Generating Permutations and Combinations.
Resource-Constrained Project Scheduling Problem (RCPSP)
CS 104: Discrete Mathematics
Intro. ANN & Fuzzy Systems Lecture 37 Genetic and Random Search Algorithms (2)
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 5 Counting 歐亞書局.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
11.1 CompSci 102© Michael Frank Today’s topics CountingCounting –Generalized Pigeonhole Principle –Permutations –Combinations –Binomial Coefficients –Writing.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
CS336 F07 Counting 2. Example Consider integers in the set {1, 2, 3, …, 1000}. How many are divisible by either 4 or 10?
Section 6.3. Section Summary Permutations Combinations.
Sorting Chapter 14.
A Universal Turing Machine
SAT problem SAT – Boolean satisfiability problem
Discrete Math (2) Haiming Chen Associate Professor, PhD
CS100: Discrete structures
i206: Lecture 8: Sorting and Analysis of Algorithms
2.6 Applications Of Induction & other ideas Important Theorems
CSE 321 Discrete Structures
Recall Brute Force as a Problem Solving Technique
Formal Languages, Automata and Models of Computation
CMPS 2433 Chapter 8 Counting Techniques
Lecture 17 Making New Codes from Old Codes (Section 4.6)
Presentation transcript:

Generating Permutations and Combinations “Traveling Salesman Problem” – A salesman must visit 6 cities; what’s the best order in which to visit them? Assume real road distances that are not uniform….How many orders (permutations) exist?

Some numbers from the set {x 1, x 2, x 3, x 4, x 5, x 6 } Add up to 100….find which ones. How? Find all of the subsets of this set…or, the power set. There are 2 n possibilities. Generating Permutations and Combinations

A laboratory has 95 employees. A group of 12 of them with a particular set of 25 skills is needed for a project. How do we select them? Theorem 2: There are C(n+r-1,r) r- combinations from a set with n elements when repetition of elements is allowed Generating Permutations and Combinations

Generating Permutations To generate all of the permutations of a set… 1.Place the elements of the set in one-to-one correspondence with the set {1, 2, 3…n} 2.List the permutations of the set of elements by generating the permutations of the n integers, then replacing them with the corresponding set elements. Procedure for this based on: Lexicographic ordering: Permutations ordered based on precedence: a 1, a 2,… a n precedes b 1, b 2,… b n if for some k from 1 to n, a 1 = b 1, a 2 = b 2,… but a k < b k.

Lexicographic Ordering Generate the permutations of the integers 1, 2, 3 in lexicographic order. {1, 2, 3}

Lexicographic Ordering What is the lexicographic ordering of the following members of the set {1, 2, 3, 4, 5}?? What is the permutation that follows 52143? 52144? NO!!!! This is not a permutation.

Lexicographic Ordering What is the next after in lexicographic ordering of the set {1, 2, 3, 4, 5}?? 1.Begin by swapping the last two elements: 52134…. But this is smaller 2.Rearrange the last THREE elements: 52431, 52314, 52413, 52341….which is next in order? < < < So…52314.

Generating Next Largest See Algorithm 1, Page 346

Generating Combinations To generate all of the combinations of a set… Since a combination is just a subset, use the correspondence between the subsets of the set {1, 2, 3…n} and the bit string of length n. There are 2 n subsets Example: Find the next largest 2-combination of {1, 2, 3, 4} after {2, 3}. {2,4}

Generating Combinations Example: Find the next largest 4 - combination of {1, 2, 3, 4, 5, 6} after {1, 2, 5, 6}. {1, 3, 5, 6} Example: Find the next largest bit string after See algorithm 2, page 347, and algorithm 3, page 348.

Homework Page 348: 1, 3, 5, 7