neeed help with an assingment that i must submit by mid9t to day
· March 26, 2015
In statistics the mode is the most frequently occurring value in a data-set, it is not
guaranteed to be unique e.g. 3,2,2,4,5,6,1,4,3,2,10,1,1 the modes are 1 and 2.
Write a function based C++ program to calculate the modal values in an array of
integers. The size of this array should be set by a constant in a header file. Since the
result is not always a single value your function must populate a results array.
Write a separate test function which uses predetermined arrays to test your library.
Write a separate test function which uses randomly generated arrays to test your
Write a menu system which allows the user to select between randomly generated
values and predetermined test data
Post a Reply
|Oldest Newest Rating|
· March 26, 2015
No one is going to do the assignment for you especially on such short notice.
I won't write the code, but I can suggest a general order of doing things.
1)create the header file and declare the constant that will be the size.
2) In that header file, declare constant arrays of the required size. One of them should one mode, one should have two, and maybe one with three although for only the basics, have 2 constant arrays with prepopulated values.
3)Write code that can calculate the mode. It really isn't that hard. I would go through the array once using an stl map from ints to ints. Then store each value found with 0. Then go through the array again and increment each counter by 1 within the map. Then find the largest count. Next for every key in the map, if that count is the largest, add the key to a linked list.
4) Write a function using stdlib that uses the rand function to populate an array.
5) Get input after asking if they want to use random values or not? If they don't, then allowing them to enter numbers until they have reached the size specified in the header file and assign that into an array that way.
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|