# Please do not post homework # Lucy Martinez, 04-24-22, Assignment 25 read `C25.txt`: #----------------------Problem 3-----------------------# # Write a procedure RandCent(n,p,K) that generates a random centipded pair G,R (rewards), where G is RDG(n,p) # and the payoffs for the sinks of G are random integers from 0 to K RandCent:=proc(n,p,K) local G,R,i: G:=RDG(n,p): R:={}: for i from 1 to nops(G) do if G[i]={} then R:= R union {[i,[ rand(1..K)(),rand(1..K)() ]]}: fi: od: G,R: end: RandCent(10,1/3,10); # [ {3, 5, 6, 9}, {5, 6, 8, 9, 10}, {5, 6, 8, 10}, {5, 8}, # {6, 7, 8, 10}, {7, 9, 10}, {8, 10}, {9, 10}, {}, {}], # {[9, [3, 6]], [10, [6, 7]]}