*expand_more*

*expand_more*

*format_list_bulleted*

**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.

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.

Therefore, the fourth pseudorandom number for current seed (cur = 37) is 49.

### Want to see more full solutions like this?

*schedule*03:09

# Chapter 3 Solutions

Data Structures and Algorithms in Java

*arrow_forward*

*arrow_forward*

*arrow_forward*

*arrow_forward*

*arrow_forward*

*arrow_forward*

*arrow_back_ios*

*arrow_forward_ios*