How would i do this

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • k1ckthem1dget
    New Member
    • Nov 2006
    • 15

    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
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by k1ckthem1dget
    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.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by k1ckthem1dget
      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.

      Comment

      • Ganon11
        Recognized Expert Specialist
        • Oct 2006
        • 3651

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

        Comment

        • DeMan
          Top Contributor
          • Nov 2006
          • 1799

          #5
          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)

          Comment

          Working...