Comp Sci HW Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nightaswz
    New Member
    • Feb 2008
    • 1

    Comp Sci HW Question

    hey guys! not only am i a bit new to the forums, but im also quite new to comp sci itself. i got a hw question that im not sure as to how to make of it. anyone able to help?
    i have to write the algorithm below in java format =/

    An algorithm gets as input a list of k integer values n1,n2,..nk, as well as a special value SUM. your algorithm must locate the a pair of values in the list N that sum to the value SUM. For example, if your list of values is 3,8,13,2,17,18, 10 and SUM was 20, then your algorithm would output either the two values (2,18) or (3,17). if your algorithm cannot find any pair of values that sum to the value SUM, then it should print out the message "sorry, there is no such pair of values"\

    thanks a lot guys!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by nightaswz
    hey guys! not only am i a bit new to the forums, but im also quite new to comp sci itself. i got a hw question that im not sure as to how to make of it. anyone able to help?
    i have to write the algorithm below in java format =/

    An algorithm gets as input a list of k integer values n1,n2,..nk, as well as a special value SUM. your algorithm must locate the a pair of values in the list N that sum to the value SUM. For example, if your list of values is 3,8,13,2,17,18, 10 and SUM was 20, then your algorithm would output either the two values (2,18) or (3,17). if your algorithm cannot find any pair of values that sum to the value SUM, then it should print out the message "sorry, there is no such pair of values"\

    thanks a lot guys!
    1.) There is no such thing as an algorithm in Java (or any other language) format.
    2.) What have you done so far?

    Comment

    Working...