473,378 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How would i do this

I need to create an array with 11 integers. They are 1,2,3,3,3,2,2,1,3,4,5.

I need to create an array from the source data list.

And I need to determine the mode of the array from above.

The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


Thanks much
Nov 30 '06 #1
4 1103
Banfa
9,065 Expert Mod 8TB
I need to create an array with 11 integers. They are 1,2,3,3,3,2,2,1,3,4,5.

I need to create an array from the source data list.

And I need to determine the mode of the array from above.

The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.
This is paradoxical because you list of numbers clear contains duplicates but your last sentence states that no value exists in the array more than once.
Nov 30 '06 #2
r035198x
13,262 8TB
I need to create an array with 11 integers. They are 1,2,3,3,3,2,2,1,3,4,5.

I need to create an array from the source data list.

And I need to determine the mode of the array from above.

The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


Thanks much
Do you want the program to output an error message if the list does not have a mode then?. ie if every number occurs once then print error.

Also you will want to post what you have tried so far so that we both benefit from the exercise.
Nov 30 '06 #3
Ganon11
3,652 Expert 2GB
I think what he is saying is that he needs to be able to determine the mode IF ONE EXISTS. That is, for the list he has provided, he needs some function to determine that the mode is 3 (occuring 4 times). If another list, however, had the values 1, 3, 5, 7, and 9, then there is no mode - his function should return a value indicating that.

If you know that the numbers have a limited range (i.e. must be between 1 and 100, or 25 and 50, or any range necessary), you can create an integer array of that size, with the indexes corresponding to each number. Then it would be a simple matter of traversing your list and incrementing the proper value in your second array. Finally, you return the largest value in your second array.
Nov 30 '06 #4
DeMan
1,806 1GB
This is question has been answered several times before in your own posts. I suggest you have a look at those suggestions. If they are not quite as helpful as you need, try to clarify your requirements (start with why those programs are nopt helpful). It would also be helpful to know:
Will the Array ALWAYS have 11 integers?
Is there restrictions on the values of teh integers (eg <10)?
Will the same numbers always be used (I assume not but this isn't clear)?

Beyond this it may also help to specify:
How you want to gather input (command line/file)
Nov 30 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
6
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE...
1
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.