#Do not post homework #William Wang, 10/9/2020, Assignment 10 #1. #i. P1 := randperm(9); P1 := [7, 4, 2, 9, 3, 8, 6, 5, 1] P2 := randperm(9); P2 := [5, 2, 6, 8, 7, 1, 3, 9, 4] #P1*P2 = [3,8,2,4,6,9,1,7,5] #P2*P1 = [3,4,8,5,6,7,2,1,9] MulPers(P1, P2); [3, 8, 2, 4, 6, 9, 1, 7, 5] MulPers(P2, P1); [3, 4, 8, 5, 6, 7, 2, 1, 9] #They are the same! #ii. P3 := randperm(9); P3 := [4, 9, 8, 6, 2, 1, 3, 7, 5] #The inverse permutation of P3 can be obtained by listing the index of 1, followed by the index of 2,.... index of 9 #1/P3 = [6, 5, 7, 1, 9, 4, 8, 3, 2] InvPer(P3); [6, 5, 7, 1, 9, 4, 8, 3, 2] #They are the same! #iii. P4 := randperm(9); P4 := [5, 7, 1, 4, 9, 8, 3, 6, 2] #Cycle structure of P4 is (4)(8,6)(9,2,7,3,1,5) PtoC(P4); [[4], [8, 6], [9, 2, 7, 3, 1, 5]] #They are the same! #iv. P5 := randperm(9); P5 := [7, 1, 3, 5, 2, 8, 9, 6, 4] #Number of inversions of P5 should be 6 + 0 + 1 + 2 + 0 + 2 + 2 + 1 + 0 = 14 #Major index should be 1 + 4 + 7 + 8 = 20 inv(P5); 14 maj(P5); 20 #They are the same!