Results 1 to 4 of 4

Thread: How to find a mode in an Array set

  1. #1
    Join Date
    May 2008
    Posts
    255

    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.

  2. #2
    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.

  3. #3
    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++;          // <-------------------------
                    }
                }

  4. #4
    Join Date
    Feb 2006
    Posts
    159

    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?

Similar Threads

  1. Replies: 5
    Last Post: 26-03-2010, 01:21 PM
  2. Unable to find elements of a given type in an array in C#
    By Kasper in forum Software Development
    Replies: 4
    Last Post: 09-02-2010, 06:46 PM
  3. Assigning an array to an array
    By MACE in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 05:19 PM
  4. How to find second largest value from array
    By Jaheel in forum Software Development
    Replies: 3
    Last Post: 18-11-2009, 11:42 AM
  5. To find key in array for Javascript.
    By Austinage in forum Software Development
    Replies: 3
    Last Post: 31-07-2009, 08:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,009,417.75187 seconds with 16 queries