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
- In the final answer the (X+Y+Z) is repeated twice. Do I have to remove one of it?arrow_forwarddecided to write an infinite sequence. Initially, he wrote 00, and then he started repeating the following process: Look at the last element written so far (the ll-th element if the sequence has length ll so far); let's denote it by xx. If xx does not occur anywhere earlier in the sequence, the next element in the sequence is 00. Otherwise, look at the previous occurrence of xx in the sequence, i.e. the kk-th element, where k<lk<l, this element is equal to xx and all elements between the k+1k+1-th and l−1l−1-th are different from xx. The next element is l−kl−k, i.e. the distance between the last two occurrences of xx. The resulting sequence is (0,0,1,0,2,0,2,2,1,…)(0,0,1,0,2,0,2,2,1,…): the second element is 00 since 00 occurs only once in the sequence (0)(0), the third element is 11 since the distance between the two occurrences of 00 in the sequence (0,0)(0,0) is 11, the fourth element is 00 since 11 occurs only once in the sequence (0,0,1)(0,0,1), and so on. Chef has given…arrow_forwardInstrument FrequencyCounter to use Stopwatch and StdDraw to make a plot where the x-axis is the number of calls on get() or put() and the y-axis is the total running time, with a point plotted of the cumulative time after each call. Run your program for Tale of Two Cities using SequentialSearchST and again using BinarySearchST and discuss the results. Note : Sharp jumps in the curve may be explained by caching, which is beyond the scope of this question.arrow_forward
- Given /(224), = (13), . The value of the radix'r isarrow_forwardWhat is the count of positive and negative charges in the amino acid sequence “YEVHHQKLVFFAEDVGSNKGAIIGLMVGGVV”? (Solve this using Python; not by hand). Compute the transition matrix for the sequence in “dna.txt”. The transition matrix tells you the number of times you move from one nucleotide to another. For instance, in the sequence AATACGAT, AA occurs once, AT occurs twice, AC occurs once, TA occurs once, CG occurs once, GA occurs once, and all other combinations occur 0 times. Print out the transition matrix. (here imagine Dna.txt is a dna sequence file)arrow_forwardCompute the following: (80+ 135) (mod 8) = (80.135) (mod 8) = =arrow_forward
- Write a code using wolfram mathematica. Please show me how to do itarrow_forwardTransform “(p ≡q) •(q ⊃ r • -p)” into conjunctive normal form; then simplify the normal form as much as possible. Use step-by-step substitutions to reach the answer, with a note in the margin your justification for each step.arrow_forwardA particular random number generator is able to give a bunch of random integers from 0 to 65535. How many numbers do you need from this generator to guarantee that there existst two subsets of integers that sum to the same number?arrow_forward
- What is Benford’s Law? Benford’s Law involves looking at the first digit of a series of numbers. For example, suppose that you were to use a random number generator to generate integers in the range of 100 to 999 and you looked at how often the number begins with 1, how often it begins with 2, and so on. Any decent random number generator would spread the answers out evenly among the 9 regions, so we’d expect to see each digit about one-ninth of the time (11.1%). But with a lot of real-world data, we see a very different distribution. The expected distribution under Benford’s Law is shown below:1: 30.1%, 2: 17.6%, 3: 12.5%, 4: 9.7%, 5: 7.9%, 6: 6.7%, 7: 5.8%, 8: 5.1%, 9: 4.6% You should use this distribution in your program. You are being provided with a text file giving population data for 247 countries and territories. Your program should read in the data in this file and extract the information needed to keep count of how often each first digit is found. It may be useful to know…arrow_forwardUsing the digits 1, 2, 3, 5, 6, 7, 8 and 9, how many three-digit numbers can be made. three-digit numbers can be made without repeating digits. five-digit numbers can be made. five-digit numbers can be made without repeating digits.arrow_forwardWrite a Python generator for the first n Catalan numbers.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education