Opracowanie językowe dr inż. J. Jarnicki

Slides:



Advertisements
Similar presentations
Z-Plane Analysis DR. Wajiha Shah. Content Introduction z-Transform Zeros and Poles Region of Convergence Important z-Transform Pairs Inverse z-Transform.
Advertisements

Internet Engineering Czesław Smutnicki Discrete Mathematics – Combinatorics.
Size-estimation framework with applications to transitive closure and reachability Presented by Maxim Kalaev Edith Cohen AT&T Bell Labs 1996.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 6.
PASSING PARAMETERS 1. 2 Parameter Passing (by Value) Parameters Formal Parameters – parameters listed in the header of the function Variables used within.
Internet Engineering Czesław Smutnicki Discrete Mathematics – Graphs and Algorithms.
Recursion practice. Problem 0 Using recursion (and no arrays), write the code to read in a series of numbers (until EOF) and then print them backwards.
EAs for Combinatorial Optimization Problems BLG 602E.
Transforming Cabbage into Turnip: Polynomial Algorithm for Sorting Signed Permutations by Reversals Journal of the ACM, vol. 46, No. 1, Jan 1999, pp
1 Sorting by Transpositions Based on the First Increasing Substring Concept Advisor: Professor R.C.T. Lee Speaker: Ming-Chiang Chen.
Exercise Computing the cyclomatic complexity Philippe CHARMAN Last update:
1 A Simpler 1.5- Approximation Algorithm for Sorting by Transpositions Combinatorial Pattern Matching (CPM) 2003 Authors: T. Hartman & R. Shamir Speaker:
Internet Engineering Czesław Smutnicki Discrete Mathematics – Computational Complexity.
10.3 – Using Permutations and Combinations Permutation: The number of ways in which a subset of objects can be selected from a given set of objects, where.
C++ function call by value The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter.
Contents of Chapter 5 Chapter 5 Dynamic Programming
Probability and Statistics Dr. Saeid Moloudzadeh Counting Principle/ Permutations 1 Contents Descriptive Statistics Axioms of Probability.
 期中测验时间:  10 月 31 日上午 9 : 40—11 : 30  第一到第四章  即,集合,关系,函数,组合数学.
Sorting an array bubble and selection sorts. Sorting An arrangement or permutation of data An arrangement or permutation of data May be either: May be.
Introduction to Real Analysis Dr. Weihu Hong Clayton State University 8/19/2008.
The least known length of ordered basis of symmetric group S. A. Kalinchuk, Yu. L. Sagalovich Institute for Information Transmission Problems, Russian.
Internet Engineering Czesław Smutnicki Discrete Mathematics – Numbers Theory.
Combinatorics University of Akron Programming Team 9/23/2011.
String as Arrays, Array Sorting C++ Programming Technologies.
Internet Engineering Czesław Smutnicki Discrete Mathematics – Recursive Equations.
Path kernels and partitions Peter Katrenič Institute of Mathematics Faculty of Science P. J. Šafárik University, Košice.
Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT9: Pointer I CS2311 Computer Programming.
Two-Dimensional Arrays and Matrices ELEC 206 Computer Applications for Electrical Engineers.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
Recitation Class IX. Content Style Pointer Style Some examples in Yahtzee.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Combinatorial problems Jordi Cortadella Department of Computer Science.
Starting Out with C++, 3 rd Edition 1 Sorting Arrays.
Static Variables. Function Scope  “Normal” local variables go out of scope and are deallocated when a function terminates.
C++ : Operator overloading example
Opracowanie językowe dr inż. J. Jarnicki
Opracowanie językowe dr inż. J. Jarnicki
#define #include<iostream> using namespace std; #define GO
Properties of Operations
Opracowanie językowe dr inż. J. Jarnicki
Computing Connected Components on Parallel Computers
Opracowanie językowe dr inż. J. Jarnicki
Opracowanie językowe dr inż. J. Jarnicki
Opracowanie językowe dr inż. J. Jarnicki
Shop Scheduling Problem
Sorting array The bubblesort.
ME 521 Computer Aided Design 15-Optimization
Combinatorics.
دانشگاه شهیدرجایی تهران
CS150 Introduction to Computer Science 1
Introduction to Programming
تعهدات مشتری در کنوانسیون بیع بین المللی
Combinatorics.
Introduction to Programming
The General Triangle C B A.
Examples of Basic Blocks
CS150 Introduction to Computer Science 1
CSE 321 Discrete Structures
Combinatorics.
The General Triangle C B A.
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
Using Permutations and Combinations
CS150 Introduction to Computer Science 1
Engine Part ID Part 1.
Engine Part ID Part 2.
Engine Part ID Part 2.
Reading from and Writing to Files Part 2
CS150 Introduction to Computer Science 1
10.3 – Using Permutations and Combinations
Presentation transcript:

Opracowanie językowe dr inż. J. Jarnicki Internet Engineering Czesław Smutnicki Discrete Mathematics – Combinatorics

CONTENTS Functions and distributions Combinatorial objects K-subsets Sequences Set partitions Number partitions Stirling numbers Bell numbers Permutations Set on/off rule

FUNCTIONS AND DISTRIBUTIONS X elements, Y boxes X Y Element can be packed to any box: n-length sequence Each box contains at most one element: set partition Box contains exactly one element: permutation

K-SUBSETS Generate all subsets with k-elements from the set of n elements 1234 1235 1236 1245 1246 1256 1345 1346 1356 1456 2345 2346 2356 2456 3456

SUBSETS 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 1010 11 1011 12 1100 13 1101 14 1110 15 1111

SET PARTITION (1) (1)(2) (1,2) (1,3)(2) (1)(2,3) (1)(2)(3) (1,2,3) (1,2)(3)

NUMBER PARTITION 7 6 1 5 2 5 1 1 4 3 4 2 1 4 1 1 1 3 3 1 3 2 1 1 3 1 1 1 1 2 2 2 1 2 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1

SECOND TYPE STIRLING NUMBERS

BELL NUMBERS n Bn 1 2 3 5 4 15 52 6 203 7 877 8 4140

PERMUTATIONS. INTRODUCTION Inverse permutation Id permutation Composition Inversions Cycles Sign

PERMUTATIONS. DISTANCE MEASURES Move type API NPI INS DA (, ) DS (, ) DI (, ) measure n minus the number of cycles in -1 o  n minus the lenght of the maximal increasing subsequence in -1 o  number of inversion in -1 o  receipt mean variance complexity

GENERATING PERMUTATIONS. IN ANTYLEXICOGRAPHICAL ORDER void swap(int& a, int& b) { int c=a; a=b; b=c; } void reverse(int m) { int i=1,j=m; while (i<j) swap(pi[i++],pi[j--]); } void antylex(int m) { int i; if (m==1) { for (i=1;i<=m;i++) cout << pi[i] << ' '; cout << endl; } else for (i=1;i<=m;i++) { antylex(m-1); if (i<m) { swap(pi[i],pi[m]); reverse(m-1); }} }

GENERATING PERMUTATIONS. MINIMAL NUMBER OF TRANSPOSITIONS void swap(int& a, int& b) { int c=a; a=b; b=c; } int B(int m, int i) { return (!(m%2)&&(m>2))?(i<(m-1)?i:m-2):m-1; } void perm(int m) { int i; if (m==1) { for (i=1;i<=n;i++) cout << pi[i] << ' '; cout << endl; } else for (i=1;i<=m;i++) { perm(m-1); if (i<m) swap(pi[B(m,i)],pi[m]); } }

GENERATING PERMUTATIONS. MINIMAL NUMBER OF ADJACENT SWAPS void swap(int& a, int& b) { int c=a; a=b; b=c; } void permtp(int m) { int i,j,x,k; int *c=new int[m+1],*pr=new int[m+1]; for (i=1;i<m;i++) { pi[i]=i; c[i]=1; pr[i]=1; } c[m]=0; for (j=1;j<=n;j++) cout << pi[j] << ' '; cout << endl; i=1; while (i<m) { i=1; x=0; while (c[i]==(m-i+1)) { pr[i]=!pr[i]; c[i]=1; if (pr[i]) x++; i++; } if (i<m) { k=pr[i]?c[i]+x:m-i+1-c[i]+x; swap(pi[k],pi[k+1]); c[i]++; for (j=1;j<=n;j++) cout << pi[j] << ' '; cout << endl; } delete[] c; delete[] pr;

Thank you for your attention DISCRETE MATHEMATICS Czesław Smutnicki