Results 1 to 4 of 4

Math Help - Please write Psedocode

  1. #1
    Newbie
    Joined
    Dec 2008
    Posts
    6

    Please write Psedocode

    Write an algorithm that searches a sequence S, of length n, for the number of negative elements. The algorithm should return the number of negative elements.


    i am appreciate for any potential answers from anybodies.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by swikar.maths View Post
    Write an algorithm that searches a sequence S, of length n, for the number of negative elements. The algorithm should return the number of negative elements.


    i am appreciate for any potential answers from anybodies.
    Initialise a counter to zero, then loop over the elements of the sequence incrementing the counter by one every time the element in the sequence is negative, return the counter.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2008
    Posts
    6

    Write an algorithms return negative elements

    Hello Captainblack,
    you answered my question regarding Psedocode.
    Please can you please writedown in Psedocode language like count = 0
    for loop..

    Please,
    Thnaks,
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by swikar.maths View Post
    Hello Captainblack,
    you answered my question regarding Psedocode.
    Please can you please writedown in Psedocode language like count = 0
    for loop..

    Please,
    Thnaks,
    There is no such thing as "Pseudo-Code", you make it up as you go, the key thing is that it can be translated unambiguously into a programming language. In which case:

    Code:
    Initialize a counter to zero, then loop over the elements of the sequence incrementing the counter by one every time the element in the sequence is negative, return the counter.
    is pseudo-code, as is:

    Code:
    Initialize a counter to zero,
    Loop over the elements of the sequence
      Increment the counter by one every time the element is negative, 
    return the counter.
    or:

    Code:
    counter=0
    for idx=1 to n
      if S(idx)<0
        counter=counter+1
      endif
    endfor
    return counter
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] Can i write 1n?
    Posted in the Algebra Forum
    Replies: 2
    Last Post: February 12th 2011, 03:25 AM
  2. Replies: 8
    Last Post: November 7th 2010, 02:11 PM
  3. I need to write this DE
    Posted in the Differential Equations Forum
    Replies: 1
    Last Post: April 17th 2010, 12:07 PM
  4. trying to write with Tex
    Posted in the LaTeX Help Forum
    Replies: 7
    Last Post: October 26th 2009, 04:20 PM
  5. Replies: 7
    Last Post: January 3rd 2007, 04:55 AM

Search Tags


/mathhelpforum @mathhelpforum