472,811 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

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

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.