> > #ATTENDANCE QUIZ FOR LECTURE 3 of Dr. Z.'s Math454(02) Rutgers University > > # Please Edit this .txt page with Answers > > #Email ShaloshBEkhad@gmail.com > #Subject: p3 > #with an attachment called > #p3FirstLast.txt > #(e.g. p3DoronZeilberger.txt) > > #Right after finishing watching the lecture but no later than Sept. 14, 2020, 8:00pm ; > #Q1. THE FIRST ATTENDANCE QUESTION WAS: > #What is a derangement ; > ; > #A1. MY ANSWER TO THE FIRST ATTENDANCE QUESTION IS: > ; > #a derangement is a permutation that has no fixed points. ; > ; > #Q2. THE SECOND ATTENDANCE QUESTION WAS: > ; > #Give two examples of WtoS and StoW ; > ; > #A2. MY ANSWER TO THE SECOND ATTENDANCE QUESTION IS: > #WtoS(w): inputs a word in {0,1} outputs the correpsonding subset of {1,...,n} (where n=nops(w)) ; > WtoS:=proc(w) local n,i,S: > > n:=nops(w): > > S:={}: > > for i from 1 to n do > if w[i]=1 then > S:=S union {i}: > fi: > od: > > S: > > end: > WtoS([0,0,1]) {3} ; > #StoW(S,n): inputs a subset S of {1,...,n} and outputs the corresponding binary word ; > StoW:=proc(S,n) local i,w: > > if S minus {seq(i,i=1..n)}<>{} then > print(S, `is not a subset of`, {seq(i,i=1..n)} ): > RETURN(FAIL): > fi: > > w:=[]: > > for i from 1 to n do > > if member(i,S) then > w:=[op(w),1]: > else > w:=[op(w),0]: > fi: > > od: > > w: > > end: > StoW({3,2,3},3) [0, 1, 1] ; > ; > #Q3. THE THIRD ATTENDANCE QUESTION WAS: > ; > #PROVE THAT THE PERMUTATIONS OF [1,2,3,...,n] is n! ; > ; > #A3. MY ANSWER TO THE THIRD ATTENDANCE QUESTION IS: > ; > #For 1st we have n possibilities, for 2nd we have n-1 possibilities, for 3rd we have n-2 possibilities ; > #So the total is n*(n-1)*(n-1)*...*1, which is n! ;