1. process p var bnow, b : boolean {init. false} begin true -> send data(bnow) to q [] rcv ack(b) from q -> if b=bnow -> bnow:=~bnow; send data(bnow) to q [] b!=bnow -> skip fi end process q var cnow, c : boolean {init. false} begin rcv data(c) from p -> if c=cnow -> {store date} cnow:=~cnow [] c!=cnow -> skip fi; send ack(c) to p end 2. timeout (wait ^ (#ch.p.q + #ch.q.p =0)) 3. process p const n input m : integer {m>0} var conp : boolean, {init. false} cansnd : 0..m, x : 0..n-1 {init. any} par y : 0..n-1 begin timeout (~conp ^ (#ch.p.q[x]+#ch.q[x].p=0)) -> send crqst to q[x] [] rcv crply from q[x] -> conp, cansnd := true, m [] conp -> if cansnd > 0 -> send data to q[x]; cansnd := cansnd - 1 [] true -> send drqst to q[x]; cansnd := 0 fi [] rcv drply from q[y] -> if x=y -> conp, x := false, any [] x!=y -> skip fi end Note: if your last action was rcv drply from q[x] -> conp, x := false, any and everything else was correct, then you still get the full credit. 4. To detect r bits of corruption burst, n has to be greater than or equal to r. Therefore, n>=r --(1) b = m*n+n = (m+1)*n --(2) From (1) and (2), If 1<=b<100 then 1<=(m+1)*n<100 & n>=10 : -0.9<=m<9 & n>=10 If 100<=b<200 then 100<=(m+1)*n<200 & n>=15 : 5.6<=m<12.3 & n>=15 If 200<=b<300 then 200<=(m+1)*n<300 & n>=24 : 7.3<=m<11.5 & n>=24 k, the number of parity bits, is equal to n, so (k/(m*n)) is equal to 1/m. To minimize 1/m, we need to choose the maximum number of m. Therefore, m=12 Now from m=12 and (2), 100<=b<200 & n>=15 100<=13*n<200 & n>=15 7.7<=n<15.4 & n>=15 Therefore, n=15 The optimal values of m and n are 12, 15 respectively.