Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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 then how many permutations exist? CODING TASK: Write a program to generate all the permutations of a set of integers, and to count the number generated. Does your program verify your answer to the question, above?

2

3 http://www.cut-the-knot.org/Curriculum/Combinatorics/JohnsonTrotter.shtml Initialize the first permutation with <1 <2... <n while there exists a mobile integer find the largest mobile integer k swap k and the adjacent integer it is looking at reverse the direction of all integers larger than k Based on the Johnson Trotter algorithm

4 My solution is based on this algorithm, but makes a few changes to make the Java implementtation easy to understand – … /~gibson/Teaching/MAT7003/Code/Permutations.zip


Download ppt "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."

Similar presentations


Ads by Google