Download presentation
Presentation is loading. Please wait.
Published byJeremy Booth Modified over 9 years ago
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?
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.