Results 1 to 3 of 3

Math Help - discrete math question please help

  1. #1
    Newbie
    Joined
    Nov 2008
    Posts
    11

    Unhappy discrete math question please help

    we were given this problem by our teacher but i am clueless on what to do. any help would be greatly appreciated.

    explain what is happening in the pseudo code LOOP in one word. What is the temp referring, and what is the final output for this program:

    input (12,25,11,28,14)

    BEGIN
    temp := a1
    for I = 2 to n
    if temp < ai then temp := ai
    END
    Print temp
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member
    Joined
    Nov 2008
    Posts
    461
    Hi

    Quote Originally Posted by dblbac View Post
    we were given this problem by our teacher but i am clueless on what to do. any help would be greatly appreciated.

    explain what is happening in the pseudo code LOOP in one word. What is the temp referring, and what is the final output for this program:

    input (12,25,11,28,14)

    BEGIN
    temp := a1
    for I = 2 to n
    if temp < ai then temp := ai
    END
    Print temp

    The input are some numbers, 12, 25,11,28,14
    they are unsorted.

    BEGIN

    temp:=a1

    temp = 12 (the first element of your list)

    for I = 2 to n

    if temp <a_i (temp < a_2, that means i.e. if 12 < 25, then)
    then temp := ai

    temp = 25

    well, i know this is not a good explanation, but this program searches a list (input) and the output is the biggest number (here 28)
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2008
    Posts
    11

    THANKS

    thanks for the help
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Discrete/CS math question
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: February 12th 2010, 03:23 AM
  2. Discrete math question about sets.
    Posted in the Discrete Math Forum
    Replies: 2
    Last Post: April 23rd 2009, 07:05 PM
  3. Discrete Math question
    Posted in the Discrete Math Forum
    Replies: 2
    Last Post: January 24th 2009, 07:05 PM
  4. Discrete math set question someone help?? thank you
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: March 24th 2008, 11:36 AM
  5. Discrete Math/Geometry Question Help!
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: September 12th 2007, 06:38 AM

Search Tags


/mathhelpforum @mathhelpforum