Chapter 2: Problem 23
Design and implement an algorithm that gets as input a list of \(k\) integer values \(N_{1}, N_{2}, \ldots, N_{k}\) as well as a special value SUM. Your algorithm must locate 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 the value of SUM is 20, then your algorithm would output either of 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 the message 'Sorry, there is no such pair of values'.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.