Results 1 to 4 of 4

Math Help - Mathematics: Discrete-Mathematics (Algorithems)

  1. #1
    Junior Member
    Joined
    Nov 2008
    Posts
    26

    Mathematics: Discrete-Mathematics (Algorithems)

    I am new to Discrete math and i do not know how to solve this sum if some can please help me ..

    Describe an algorithm that takes as input a list of n integer and produce as out put the largest difference obtained by subracting an integer in the list from the one following it.
    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 bhuvan View Post
    I am new to Discrete math and i do not know how to solve this sum if some can please help me ..

    Describe an algorithm that takes as input a list of n integer and produce as out put the largest difference obtained by subracting an integer in the list from the one following it.
    Code:
    diffmin=diffrence between first and second input
    Loop over inputs from second to the (n-1)st
      diffwrk=current input minus next input
      if diffwrk<diffmin
        diffmin=diffwrk
      endif
    endLoop
    
    return diffmin
    CB
    Last edited by CaptainBlack; November 2nd 2008 at 06:28 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Nov 2008
    Posts
    26
    Thank you very much but how i can write algorithm in mathematical term..??
    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 CaptainBlack View Post
    Code:
    diffmin=diffrence between first and second input
    Loop over inputs from second to the (n-1)st
      diffwrk=current input minus next input
      if diffwrk<diffmin
        diffmin-diffwrk
      endif
    endLoop
     
    return diffmin
    CB
    Quote Originally Posted by bhuvan View Post
    Thank you very much but how i can write algorithm in mathematical term..??
    Well I would write it in a more formal pseudo-code:

    Code:
    1:   input x(1..n)
     
    2:   diffmin:=x(2)-x(1)
    3:   for idx=2 to n-1
    3.1:    diffwrk:=x(idx+1)-x(idx)
    3.2:    if diffwrk<diffmin
    3.2.1:    diffmin:=diffwrk;
     
    4:   return diffmin
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. discrete mathematics
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: October 1st 2010, 05:39 PM
  2. Discrete Mathematics GCD Question
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: February 5th 2010, 11:48 AM
  3. Discrete mathematics question
    Posted in the Discrete Math Forum
    Replies: 4
    Last Post: February 4th 2010, 01:55 PM
  4. What is discrete Mathematics About ?
    Posted in the Discrete Math Forum
    Replies: 7
    Last Post: June 4th 2009, 09:28 PM
  5. discrete mathematics..help!!!!!
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: September 12th 2008, 04:43 AM

Search Tags


/mathhelpforum @mathhelpforum