Question
Assume that the function random(n) returns an integer selected uniformly randomly from the set {1, 2, 3, . . . , n}. For example, random(4)
Assume that the function random(n) returns an integer selected uniformly randomly from the set {1, 2, 3, . . . , n}. For example, random(4) would return either 1, 2, 3 or 4, with equal probability. Here is some code that uses random selections. 1 x random(10) 2 y random(20) 3 z random(30)
a) Let N be the total number of distinct combinations of (x, y, z). Calculate N . Note that (x, y, z) = (1, 1, 2) is distinct from (x, y, z) = (2, 1, 1), etc.
b)In each of the following questions, you are asked for the number of combinations of (x, y, z) that satisfy a certain condition. Strategy: fix an arbitrary x, and determine the number of possible values of y and z in terms of x. Then sum the result over x. Do not evaluate the summation notation. Sample answer: 10
10x x=1 Find an expression for... (i) [1 mark] NA, the number of combinations such that x y. (ii) [1 mark] NB , the number of combinations such that x < y and 2x z. (iii) [1 mark] NC , the number of combinations such that x < y and x z < 2x. (iv) [1 mark] ND, the number of combinations such that x < y and x > z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started