An urn containing n balls can be represented by the set U = {b1, b2, ... , bn}. Interpret the following algorithm in the context of urn problems. Does it represent drawing with or without replacement? How many lines does it print? for i is in {1, 2, ... , n} do for j is in {1, 2, ... , n} do for k is in {1, 2, ... , n} do print bi, bj, bk The algorithm prints out all the possible ways to draw balls in sequence,
What would be the first (bi,bj,bk) to be printed?
im not sure.. bi?
On the fourth line, you have "pritn bi,bj,bk". You print three numbers on the same line. What are they?
the outer loop: i starts with value 1, then we start the 2nd loop. -> j takes first value 1, and for j=1, we go to the third loop, where k=1,2,...,n. When k=1 for the first time, we have i=1 and j=1. Therefore the first line printed is (b1,b1,b1). This is a drawing from an experience WITH replacement.
ok so for the second its bj,bj,bj and third b1,b1,b1?
no. these are nested loops. That means, when i=1, and j=1. you will go through all values of k. Review this topic carefully.
@e.mccormick
what is the answer?!?
Join our real-time social learning platform and learn together with your friends!