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
- Now add the-dflag, and change the number of loops (-l) from 1 to highernumbers. What happens? Does the code (always) deadlock?arrow_forwardQ4/Full the following blanks (1101 1010)BCD(5211) = ( )BCD(3321)=()EX-3=()16 * (1101 1010)BCD(5211) = (1110 1100)BCD(3321)=(1010110)EX-3= (A6)16 (1101 1010)BCD(5211) = (1110 0111)BCD(3321)=(1011001)EX-3= (56)16 (1101 1010)BCD(5211) = (1101 0111)BCD(3321)=(1011001)EX-3= (2B)16 (1101 1010)BCD(5211) = (1011 1110)BCD(3321)=(1000111)EX-3= (44)16 None of them IIarrow_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_forward
- Instrument 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_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_forwardPlease help me interpret this.arrow_forward
- Write a java code for the following . Write a Java program to print the unique elements along with their frequency in the given (3x 3) integer matrix. ex. java sample outputarrow_forwardCan you help me solve this question with the code i have givenarrow_forwardCan you show me step by step thank youarrow_forward
- Please help me with this using java. Use arraysarrow_forwardRun the code to determine experimentally the distribution of the number of components in random graphs of various types by building a large number of graphs and producing a histogram.arrow_forwardA lecturer intends to separate his students into 2 groups based in their index numbers those with odd numbers in group A and Even numbers in B.Use if-else staement to implement this.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