Pseudorandom Number generation:
In Java, there is a built-in class java.util.Random whose object as pseudorandom number to determine the sequence of numbers by randomly.
Note: Refer page number 113 to formula for next pseudorandom number in the text book.
According the formula given by the text book, the current seed “cur” value is needed to find the next pseudorandom number. But, here the only one current seed “cur” is given to find the five next pseudorandom numbers.
- Apply the given inputs for five times; get the same next pseudorandom number. So, take current seed value as “next pseudorandom number” to find the next pseudorandom numbers.
Explanation of Solution
Determine the next five pseudorandom numbers:
The given inputs are,
a = 12
b = 5
n = 100
Current seed (cur) = 92
The formula for next pseudorandom number is given below:
First pseudorandom numbers:
Substitute the “a”, “b”, “n”, and “cur” in the Equation (1) to determine the first next pseudorandom number is given below:
Therefore, the first pseudorandom number for current seed (cur = 92) is 9.
Second pseudorandom numbers:
Here, let us consider the current seed “cur” as “9”. That is, result of first pseudorandom number.
Substitute the “a”, “b”, “n”, and “cur” in the Equation (1) to determine the first next pseudorandom number is given below:
Therefore, the second pseudorandom number for current seed (cur = 9) is 13.
Third pseudorandom numbers:
Here, let us consider the current seed “cur” as “13”. That is, result of second pseudorandom number.
Substitute the “a”, “b”, “n”, and “cur” in the Equation (1) to determine the first next pseudorandom number is given below:
Therefore, the third pseudorandom number for current seed (cur = 13) is 61.
Fourth pseudorandom numbers:
Here, let us consider the current seed “cur” as “61”. That is, result of second pseudorandom number.
Substitute the “a”, “b”, “n”, and “cur” in the Equation (1) to determine the first next pseudorandom number is given below:
Therefore, the fourth pseudorandom number for current seed (cur = 61) is 37.
Fifth pseudorandom numbers:
Here, let us consider the current seed “cur” as “37”. That is, result of second pseudorandom number.
Substitute the “a”, “b”, “n”, and “cur” in the Equation (1) to determine the first next pseudorandom number is given below:
Therefore, the fourth pseudorandom number for current seed (cur = 37) is 49.
Want to see more full solutions like this?
Chapter 3 Solutions
Data Structures and Algorithms in Java
- can u solve this questionarrow_forward1. Unsigned Integers If we have an n-digit unsigned numeral dn-1d n-2...do in radix (or base) r, then the value of that numeral is n−1 r² di Σi=0 which is basically saying that instead of a 10's or 100's place we have an r's or r²'s place. For binary, decimal, and hex r equals 2, 10, and 16, respectively. Just a reminder that in order to write down a large number, we typically use the IEC or SI prefixing system: IEC: Ki = 210, Mi = 220, Gi = 230, Ti = 240, Pi = 250, Ei = 260, Zi = 270, Yi = 280; SI: K=103, M = 106, G = 109, T = 10¹², P = 1015, E = 10¹8, Z = 1021, Y = 1024. 1.1 Conversions a. (15 pts) Write the following using IEC prefixes: 213, 223, 251, 272, 226, 244 21323 Ki8 Ki 223 23 Mi 8 Mi b. (15 pts) Write the following using SI prefixes: 107, 10¹7, 10¹¹, 1022, 1026, 1015 107 10¹ M = 10 M = 1017102 P = 100 P c. (10 pts) Write the following with powers of 10: 7 K, 100 E, 21 G 7 K = 7*10³arrow_forwardanswer shoul avoid using AI and should be basic and please explainarrow_forward
- Node A is connected to node B by a 2000km fiber link having a bandwidth of 100Mbps. What is the total latency time (transmit + propagation) required to transmit a 4000 byte file using packets that include 1000 Bytes of data plus 40 Bytes of header.arrow_forwardanswer should avoid using AI and should be basic and explain pleasearrow_forwardasnwer should avoid using AIarrow_forward
- answer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardWrite a c++ program that will count from 1 to 10 by 1. The default output should be: 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, —help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter, counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should…arrow_forwardshow workarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage