Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6

Thread: Pseudocode

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    37
    Member #
    3243
    Well since this is the non-web discussion forum I guess this belongs here...

    Has anyone any ideas how to write a Pseudocode algorithm for calculating the mode of a set of 10 numbers using arrays?

    I've worked out bits and pieces here and there of it ut I can't seem to get a logical "program" out at the end of it... so if anyone out there is good a bit of help would be much appreciated

    5 TD to anyone that can do it

    John

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    What do you need it for? If it's homework, we don't do that sort of thing.

  4. #3
    Member
    Join Date
    Sep 2003
    Posts
    37
    Member #
    3243
    No, writing a VB maths application that does numerous things, and following College I learnt to do everything in steps - Flowchart/Pseudocode - then into the designated language.

    Functions such as graphing, averaging (Bar mode!), triganomic (sp?) aren't too difficult as linear mathematical commands can be used and/or constants defined. Unfortunately, I've never been good with Arrays (Which it would seem I need to be using here) in any language, so that's why I posted here.

    Maybe I ought to rethink the way I type posts if I come across as an early teenager.... Or did I miss an offensive comment?

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Define array length variable for size of array and set it to 9 (this will allow you to change the size of the array if you ever need to; since 9 encompasses 0 to 9, which is 10 numbers)

    Define array of size array length variable

    Define second two-dimensional array of undetermined length and width 1; your 0 column will be your value, and your 1 column will be your frequency

    Loop from 0 to array length variable,
    - assign value to each array element (or however you want to assign the values to the array; they can come from a database, whatever)
    end your loop

    Loop from 0 to array length variable again
    - check to see if array element value matches any preassigned second array (0) values
    - if there is a match in second array (0) values, the corresponding second array (1) value increments by 1
    - if there is no match, then a new row for your second array will be created with values of array element value for (0) value and 1 for (1) value (since it's the first occurrence of the array)
    end your loop

    Sort your two-dimensional array in descending order by (1) column

    Display first (0) element in sorted array as a mode

    Display any subsequent (0) elements in sorted array where (1) element = first (1) element in sorted array as modes as well.

    This is about as close as I can write it to making sense without actually putting any programming into it.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Member
    Join Date
    Sep 2003
    Posts
    37
    Member #
    3243
    Thanks a lot TheGAME, I was missing a two dimentional array and was instead trying to recreate a similar effect with two separate arrays... which obviously was working very well!

    TD awarded (I hope)

    Regards,
    John

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Yes, I did get them. Thanks, man.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:49 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com