472,811 Members | 1,664 Online

# 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!
Feb 12 '08 #1
1 1301
r035198x
13,262 8TB
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?
Feb 12 '08 #2