Explore BrainMass
Share

C++ Linked List

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

See the attached file.

Write a program to check out how good my new random number generator generates numbers. A good generator produces evenly distributed numbers over some range. Determine how well these numbers are dispersed between 1 and 100.
generate 10,000 random numbers between 1 and 100 and count how many times each number is produced. From this test, the program is to produce several results.

a. Determine the average random number produced.
b. Determine which number(s) was generated the most often.
Need to know which random number was produced most often (the count) and if more than one, show all.
c. Determine which number(s) was generated the least often.
Need to know which random number was produced least often (the count) and if more than one, show all.

Restrictions:
Must use a link list to store data in order
Must use functions.

new random number generator is a follows:

seed = 73267217 ......starting value (first random number)

Generate the next random number using the previous random number (seed)

seed = abs( seed % 10000 + seed / 10000 ) * 732163
return seed; (newest random number).

© BrainMass Inc. brainmass.com October 25, 2018, 7:39 am ad1c9bdddf
https://brainmass.com/computer-science/random-number-generation/cplusplus-linked-list-510406

Attachments

Solution Summary

Using linked list in C++ to determine how good the random numbers generated by a generator over some ranges are distributed.

$2.19
See Also This Related BrainMass Solution

C++ Linked List that Counts Unique Entries

See the attached file.

We have a list of numbers and we need to know two things, what numbers we have and how many of each number do we have in the list.
So we read in each number and add the number to an ordered linked list. If we are adding a number to the list and we find that number, then we will just count it. If we do not find the number in the linked list, then we will add a new node to the linked list with the new number and set the count to one.

The linked list node will have three fields - the number, a counter for the number and a link field.

Write a C++ program to achieve what we want, and print out the values and their counts, say 5 per line.

Example:
5(22) 8(15) 13(5) 22(3) 25(18)
where 5 is the number and 22 is its count.

Please use the attached input file "LinkNbrs.dat" for testing the program.

View Full Posting Details