
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
8.
![}
// Driver Code
int main()
{
int Xo = 5; // Seed value
int m = 7; // Modulus parameter
int a = 3; // Multiplier term
int c = 3; // Increment term
// Number of Random numbers
// to be generated
int noOfRandomNums = 10;
// To store random numbers
vector<int> randomNums(
noOfRandomNums);
// Function Call
linearCongruentialMethod(
Хо, т, а, с,
randomNums, noOfRandomNums);
// Print the generated random numbers
for (int i = 0; i< noOfRandomNums; i++) {
cout << randomNums[i] << " ";
}
return 0;
8. Perform manually the pseudorandom number generator for numbers between 0 and 1
using the method of linear congruential method where m=9, a=7, c=4, and Xo=3.](https://content.bartleby.com/qna-images/question/ec1970a1-9dd2-43a4-8db4-a04e0fa09dee/d2e60257-eb26-4f89-98e4-1be74e0328a6/f10ssf9_thumbnail.jpeg)
Transcribed Image Text:}
// Driver Code
int main()
{
int Xo = 5; // Seed value
int m = 7; // Modulus parameter
int a = 3; // Multiplier term
int c = 3; // Increment term
// Number of Random numbers
// to be generated
int noOfRandomNums = 10;
// To store random numbers
vector<int> randomNums(
noOfRandomNums);
// Function Call
linearCongruentialMethod(
Хо, т, а, с,
randomNums, noOfRandomNums);
// Print the generated random numbers
for (int i = 0; i< noOfRandomNums; i++) {
cout << randomNums[i] << " ";
}
return 0;
8. Perform manually the pseudorandom number generator for numbers between 0 and 1
using the method of linear congruential method where m=9, a=7, c=4, and Xo=3.
![Example 1: Using C++ to implement Linear Congruential Method for generating pseudo
random numbers.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// Function to generate random numbers
void linearCongruentialMethod(int Xo, int m, int a, int c,vector<int>& randomNums,int
noOfRandomNums)
{
// Initialize the seed state
randomNums[0] = Xo;
// Traverse to generate required
// numbers of random numbers
for (int i = 1; i < noOfRandomNums; i++) {
// Follow the linear congruential method
randomNums[i]
= ((randomNums[i - 1] * a) + c) % m;](https://content.bartleby.com/qna-images/question/ec1970a1-9dd2-43a4-8db4-a04e0fa09dee/d2e60257-eb26-4f89-98e4-1be74e0328a6/3nm6jq5_thumbnail.jpeg)
Transcribed Image Text:Example 1: Using C++ to implement Linear Congruential Method for generating pseudo
random numbers.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// Function to generate random numbers
void linearCongruentialMethod(int Xo, int m, int a, int c,vector<int>& randomNums,int
noOfRandomNums)
{
// Initialize the seed state
randomNums[0] = Xo;
// Traverse to generate required
// numbers of random numbers
for (int i = 1; i < noOfRandomNums; i++) {
// Follow the linear congruential method
randomNums[i]
= ((randomNums[i - 1] * a) + c) % m;
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

Knowledge Booster
Similar questions
- HW10_4 19.21 A manufactured metal sphere has density that varies with the distance from its center. r (mm) Le (gm/cm³). 0.36 4.29 0.12 0.24 0.49 0.62 0.79 0.86 0.93 1 5.81 5.14 3.39 2.7 2.19 2.1 2.04 2 Estimate the particle's mass and average density (i.e., total mass divided by total volume) as accurately as possible. Watch units! Some helpful info: m = p(r)A(r)dr; where, A(r) = 4rtr² Print all results to the screen using fprintf.arrow_forward1.9 Suppose we use six bits to represent a two's complement binary number. (a) What is the largest number that can be represented? (b) What is the smallest number that can be represented? (c) How many total base-10 numbers can be represented?arrow_forward11. Perform each of these operations using the bases shown. a. 32five x 4five b. 32five divide 4five c. 43six x 23six d. 143five divide 3five e. 10010two divide 11two f. 10110two x 101twoarrow_forward
- 3. In the binary number system, how are numbers represented?3 With the digits 0 and 1 With the letters x and y As either "true" or "false" O Using the digits 0-9 and the letters A-Farrow_forward# Compute and print the first 10 Triangular numbers # # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 # # Row # 1 2 3 4 # o Triangular numbers can be represented in the # o form of a triangular grid of points where the # o o first row contains a single element and each # o o subsequent row contains one more element than # o o the previous one. # o # o 1, 1+(1+1)=3, 3+(2+1)=6, 6+(3+1)=10, 10+(4+1)=15, ... # # The following special case formula can be used to calculate # a particular Triangular number. 0.5n(n+1) # # Expected Output: # #1 #3 #6 #10 #15 #21 #28 #36 #45 #55 .globl main .data tna: .word 0 : 10 # array of words to contain 10 Triangular values size: .word 10 # size of "array" (agrees with array declaration) .text main: la $s0, tna # load address of target array la $s5, size # load address of array's size lw $s5, 0($s5) # load array size li $s2, 1 # 1 is the first Triangular number sw $s2, 0($s0) # tri[0] = 1 li $s1, 2 # set calculated element counter to 2 (next natural number) # Load…arrow_forward9. 2 b k 1 m r g n S a C h P d j 9arrow_forward
- Converting Hexadecimal to Binary 9. Use this table to convert the number 2F5 into binary code. Hexadecimal number Binary equivalent of each digit Final binary number ASCII and Unicode 10. Use the ASCII table on page 15 of the study to encode the phrase "Types of Data" into decimal numbers. T. y D a a Breaking Down an Image 11. An image can be broken down into small dots called and the number of these dots in an image is called the The information in these elements is represented by a collection of binary numbers called a(n)arrow_forwardʙᴇʟᴏᴡ ɪꜱ ʜᴏᴡ ᴛʜᴇ ꜰɪʟᴇɴᴀᴍᴇꜱ ᴀʀᴇ ʀᴇᴘʀᴇꜱᴇɴᴛᴇᴅᴀʀʀᴀʏ[] = [50, 11, 33, 21, 40, 50, 40, 40, 21]ʙᴇʟᴏᴡ ɪꜱ ᴛʜᴇ ᴇxᴘᴇᴄᴛᴇᴅ ᴏᴜᴛᴘᴜᴛ ᴀꜰᴛᴇʀ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴᴀʀʀᴀʏ[] = [11, 21, 33, 40, 50] ʏᴏᴜ ᴄᴀɴɴᴏᴛ ᴜꜱᴇ ʟɪʙʀᴀʀʏ ꜰᴜɴᴄᴛɪᴏɴꜱ ᴛᴏ ᴇɪᴛʜᴇʀꜱᴏʀᴛ ᴀɴᴅ ᴏʀ ᴘᴇʀꜰᴏʀᴍ ᴛʜᴇ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴏᴘᴇʀᴀᴛɪᴏɴ. ɪɴ ᴊᴀᴠᴀ ɪᴍᴘʟᴇᴍᴇɴᴛ ᴛʜᴇ ꜰᴜɴᴄᴛɪᴏɴ ɪɴ ꜱᴜᴄʜ ᴀ ᴡᴀʏ ᴛʜᴀᴛ ʏᴏᴜʀ ꜱᴏʟᴜᴛɪᴏɴ ꜱᴏʟᴠᴇꜱᴛʜᴇ ᴘʀᴏʙʟᴇᴍ ᴡɪᴛʜ ᴏ(ɴ ʟᴏɢ2(ɴ)) ᴛɪᴍᴇ ᴄᴏᴍᴘʟᴇxɪᴛʏ ᴏᴠᴇʀᴀʟʟ ʙᴜᴛ ꜱᴛᴀʏꜱ ᴡɪᴛʜɪɴ ᴛʜᴇ ʙᴏᴜɴᴅꜱ ᴏꜰ ᴏ(1) ꜱᴘᴀᴄᴇ ᴄᴏᴍᴘʟᴇxɪᴛʏ. ʜᴇʀᴇ, ɴ ɪꜱ ᴛʜᴇ ʟᴇɴɢᴛʜ ᴏꜰ ᴛʜᴇ ʟɪꜱᴛ ᴏꜰɪɴᴘᴜᴛ ɪɴᴛᴇɢᴇʀꜱ (ᴀʀʀᴀʏ). ɪ ʙᴇʟɪᴇᴠᴇ ᴛʜᴇ ꜱᴏʀᴛɪɴɢ ʀᴏᴜᴛɪɴᴇ ᴛʜᴀᴛ ᴄᴀɴ ʙᴇ ᴜꜱᴇᴅ ʜᴇʀᴇ ɪꜱ Qᴜɪᴄᴋ ꜱᴏʀᴛ. ᴘʟᴇᴀꜱᴇ ꜱᴛᴀᴛᴇ ᴀꜱ ᴄᴏᴅᴇ ᴄᴏᴍᴍᴇɴᴛ ᴡʜɪᴄʜ ꜱᴏʀᴛɪɴɢ ʀᴏᴜᴛɪɴᴇ ʏᴏᴜ ᴀʀᴇ ᴜꜱɪɴɢ, ꜱᴏʀᴛ ᴛʜᴇ ᴀʀʀᴀʏ ᴡɪᴛʜ ᴛʜᴀᴛ ᴀʟɢᴏʀɪᴛʜᴍ ᴀɴᴅ ꜱᴏʟᴠᴇ ᴛʜᴇ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴘʀᴏʙʟᴇᴍ ᴛʜᴇʀᴇᴀꜰᴛᴇʀ. ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴘᴀʀᴛ ᴏꜰ ᴛʜᴇ ꜱᴏʟᴜᴛɪᴏɴ ɪɴ ɪᴛꜱᴇʟꜰ ᴍᴜꜱᴛ ᴀᴅʜᴇʀᴇ ᴛᴏ ᴏ(ɴ) ᴛɪᴍᴇ ᴀɴᴅ ᴏ(1) ꜱᴘᴀᴄᴇ ʙᴏᴜɴᴅꜱ ᴄᴏᴍᴍᴇɴᴛ ᴇᴠᴇʀʏ ʟɪɴᴇ ᴏꜰ ᴄᴏᴅᴇᴘʟᴇᴀꜱᴇ ᴡʀɪᴛᴇ ᴛᴇꜱᴛ-ᴄᴀꜱᴇꜱ ᴏɴ ʜᴏᴡ ᴏɴᴇ ᴡᴏᴜʟᴅᴛᴇꜱᴛ ᴛʜᴇ ꜱᴏʟᴜᴛɪᴏɴ ᴀꜱꜱᴜᴍᴘᴛɪᴏɴꜱ ᴀɴᴅ ʜᴇɴᴄᴇ ᴛʜᴇ ᴄᴏᴅᴇ ᴇxᴀᴍᴘʟᴇ ᴏꜰ ᴄᴀꜱᴇꜱ ᴛᴏ ʙᴇ ᴛᴇꜱᴛᴇᴅ ꜰᴏʀ ᴀʀᴇ ʟɪᴋᴇ : ᴡʜᴀᴛ ɪꜰ ᴛʜᴇ ᴀʀʀᴀʏ ɪɴᴘᴜᴛ ᴡʜɪᴄʜɪꜱ…arrow_forwardPlease help provide answers for the following questions 2-26. The following bytes (shown in hex) represent a person’s name as it would be stored in a computer’s memory. Each byte is a padded ASCII code. Determine the name of each person. (a) 42 45 4E 20 53 4D 49 54 48 (b) Write the Phrase in ascii : I will score an A grade 2-30. Perform each of the following conversions. For some of them, you may want to try several methods to see which one works best for you. For example, a binary-to-decimal conversion may be done directly, or it may be done as a binary-to-hex conversion followed by a hex-to decimal conversion.= _2: binary _10: decimal _16: hexadecimal (a) 517_10 = _____ _2 (b) 255_10 = _____ _2 (c) 101010001_2 = _____ _10 (d) 1010101000100111_2 = _____ _10 (e) 2547_10 = _____ _16 (f) 567_10 = _____ (BCD) (g) 275_16 = _____ _10 (h) 53_10= _____ _16 (i) A79_16 = _____ _10 (j) 3ED5_16 = _____ _10 (k) 1760_10 = _____ _16 (l) 38,218_10 = ______ _16 (m)…arrow_forward
- 8,9arrow_forward[1, 3, 4, 6, 7, 7, 7, 9, 11, 12, 13, 14, 14, 15, 16, 18, 19, 22, 22, 24, 25, 27, 29, 30, 31, 34, 40, 43, 45, 46, 47, 48, 49, 49, 50, 50, 61, 64, 70, 71, 78, 96, 133, 135, 152 ] please fill these blanks using the above data my sample data within the limits of the first standard deviation is _(pick one: normally distributed, or not normally distributed)_at this measurement. my sample data within the limits of the second standard deviation is _(pick one: normally distributed, or not normally distributed)_ at this measurement. my sample data within the limits of the third standard deviation is _(pick one: normally distributed, or not normally distributed)_ at this measurement.arrow_forwardʙᴇʟᴏᴡ ɪꜱ ʜᴏᴡ ᴛʜᴇ ꜰɪʟᴇɴᴀᴍᴇꜱ ᴀʀᴇ ʀᴇᴘʀᴇꜱᴇɴᴛᴇᴅᴀʀʀᴀʏ[] = [50, 11, 33, 21, 40, 50, 40, 40, 21]ʙᴇʟᴏᴡ ɪꜱ ᴛʜᴇ ᴇxᴘᴇᴄᴛᴇᴅ ᴏᴜᴛᴘᴜᴛ ᴀꜰᴛᴇʀ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴᴀʀʀᴀʏ[] = [11, 21, 33, 40, 50] ʏᴏᴜ ᴄᴀɴɴᴏᴛ ᴜꜱᴇ ʟɪʙʀᴀʀʏ ꜰᴜɴᴄᴛɪᴏɴꜱ ᴛᴏ ᴇɪᴛʜᴇʀꜱᴏʀᴛ ᴀɴᴅ ᴏʀ ᴘᴇʀꜰᴏʀᴍ ᴛʜᴇ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴏᴘᴇʀᴀᴛɪᴏɴ. ɪɴ ᴊᴀᴠᴀ ɪᴍᴘʟᴇᴍᴇɴᴛ ᴛʜᴇ ꜰᴜɴᴄᴛɪᴏɴ ɪɴ ꜱᴜᴄʜ ᴀ ᴡᴀʏ ᴛʜᴀᴛ ʏᴏᴜʀ ꜱᴏʟᴜᴛɪᴏɴ ꜱᴏʟᴠᴇꜱᴛʜᴇ ᴘʀᴏʙʟᴇᴍ ᴡɪᴛʜ ᴏ(ɴ ʟᴏɢ2(ɴ)) ᴛɪᴍᴇ ᴄᴏᴍᴘʟᴇxɪᴛʏ ᴏᴠᴇʀᴀʟʟ ʙᴜᴛ ꜱᴛᴀʏꜱ ᴡɪᴛʜɪɴ ᴛʜᴇ ʙᴏᴜɴᴅꜱ ᴏꜰ ᴏ(1) ꜱᴘᴀᴄᴇ ᴄᴏᴍᴘʟᴇxɪᴛʏ. ʜᴇʀᴇ, ɴ ɪꜱ ᴛʜᴇ ʟᴇɴɢᴛʜ ᴏꜰ ᴛʜᴇ ʟɪꜱᴛ ᴏꜰɪɴᴘᴜᴛ ɪɴᴛᴇɢᴇʀꜱ (ᴀʀʀᴀʏ). ɪ ʙᴇʟɪᴇᴠᴇ ᴛʜᴇ ꜱᴏʀᴛɪɴɢ ʀᴏᴜᴛɪɴᴇ ᴛʜᴀᴛ ᴄᴀɴ ʙᴇ ᴜꜱᴇᴅ ʜᴇʀᴇ ɪꜱ Qᴜɪᴄᴋ ꜱᴏʀᴛ. ᴘʟᴇᴀꜱᴇ ꜱᴛᴀᴛᴇ ᴀꜱ ᴄᴏᴅᴇ ᴄᴏᴍᴍᴇɴᴛ ᴡʜɪᴄʜ ꜱᴏʀᴛɪɴɢ ʀᴏᴜᴛɪɴᴇ ʏᴏᴜ ᴀʀᴇ ᴜꜱɪɴɢ, ꜱᴏʀᴛ ᴛʜᴇ ᴀʀʀᴀʏ ᴡɪᴛʜ ᴛʜᴀᴛ ᴀʟɢᴏʀɪᴛʜᴍ ᴀɴᴅ ꜱᴏʟᴠᴇ ᴛʜᴇ ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴘʀᴏʙʟᴇᴍ ᴛʜᴇʀᴇᴀꜰᴛᴇʀ. ᴅᴇ-ᴅᴜᴘʟɪᴄᴀᴛɪᴏɴ ᴘᴀʀᴛ ᴏꜰ ᴛʜᴇ ꜱᴏʟᴜᴛɪᴏɴ ɪɴ ɪᴛꜱᴇʟꜰ ᴍᴜꜱᴛ ᴀᴅʜᴇʀᴇ ᴛᴏ ᴏ(ɴ) ᴛɪᴍᴇ ᴀɴᴅ ᴏ(1) ꜱᴘᴀᴄᴇ ʙᴏᴜɴᴅꜱ ᴄᴏᴍᴍᴇɴᴛ ᴇᴠᴇʀʏ ʟɪɴᴇ ᴏꜰ ᴄᴏᴅᴇᴘʟᴇᴀꜱᴇ ᴡʀɪᴛᴇ ᴛᴇꜱᴛ-ᴄᴀꜱᴇꜱ ᴏɴ ʜᴏᴡ ᴏɴᴇ ᴡᴏᴜʟᴅᴛᴇꜱᴛ ᴛʜᴇ ꜱᴏʟᴜᴛɪᴏɴ ᴀꜱꜱᴜᴍᴘᴛɪᴏɴꜱ ᴀɴᴅ ʜᴇɴᴄᴇ ᴛʜᴇ ᴄᴏᴅᴇ ᴇxᴀᴍᴘʟᴇ ᴏꜰ ᴄᴀꜱᴇꜱ ᴛᴏ ʙᴇ ᴛᴇꜱᴛᴇᴅ ꜰᴏʀ ᴀʀᴇ ʟɪᴋᴇ : ᴡʜᴀᴛ ɪꜰ ᴛʜᴇ ᴀʀʀᴀʏ ɪɴᴘᴜᴛ ᴡʜɪᴄʜɪꜱ…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY