Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



How to find a mode in an Array set

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-08-2009
Quattro's Avatar
Member
 
Join Date: May 2008
Posts: 256
How to find a mode in an Array set

I have some custom SharePoint site definitions but i heard that if we wanted to deploy it we have to make use of SharePoint wsp solution packages, which i have tried but it does not show anything. I have also read that a method involving hashing could be a good way to find the mode of an array of floating point numbers. Is this correct and how do it related to me.
Reply With Quote
  #2  
Old 03-08-2009
Member
 
Join Date: Oct 2008
Posts: 137
Re: How to find a mode in an Array set

First create a second array with a size of the range of your first array. So, if your array has numbers 0 to 100 in it, the array should have 101 slots. it seems the obvious way to implement this using a hash table would be to use the number as a key, and as the value stored, use a frequency counter.
Reply With Quote
  #3  
Old 03-08-2009
Member
 
Join Date: Apr 2008
Posts: 193
Re: How to find a mode in an Array set

Return sourceIndex if you want to know where the first occurrence of the element is, or sourceElement if you want to know the "value" of the element. The mode of an array of numbers is the number m in the array that is repeated most frequently. If more than one number is repeated with equal maximal frequencies, there is no mode.

Code:
for (int k = 0; k <array.length; k++){
            for (int j = k + 1; j < array.length; j++){
                if (array[k] == array[j]){
                    count++;
                    k++;          // <-------------------------
                }
            }
Reply With Quote
  #4  
Old 03-08-2009
napoleon's Avatar
Member
 
Join Date: Feb 2006
Posts: 118
Re: How to find a mode in an Array set

it always comes true and the return value is termed 0. However, without that statement and the condition that there cannot be a '0 mode' the program works fine. I would advise against using a hash, as it assumes exact comparisons -- never a good assumption on floating-point numbers. What if your array contains some elements 0.2(00000000) and 0.2(00000001), which really should be considered equal, but aren't because they came from different calculations?
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to find a mode in an Array set"
Thread Thread Starter Forum Replies Last Post
Unable to find the sleep mode on Toshiba Satellite R15 laptop Nereus Portable Devices 5 26-03-2010 02:21 PM
Unable to find elements of a given type in an array in C# Kasper Software Development 4 09-02-2010 06:46 PM
Assigning an array to an array MACE Software Development 3 18-11-2009 05:19 PM
How to find second largest value from array Jaheel Software Development 3 18-11-2009 11:42 AM
To find key in array for Javascript. Austinage Software Development 3 31-07-2009 09:13 PM


All times are GMT +5.5. The time now is 03:48 AM.