Question: Soukaina Fali Boubrahimi CSc 2720- Data Structures: Lab 7 Given an array of unique positive integers, write a function findSurns that takes the array input

 Soukaina Fali Boubrahimi CSc 2720- Data Structures: Lab 7 Given an

Soukaina Fali Boubrahimi CSc 2720- Data Structures: Lab 7 Given an array of unique positive integers, write a function findSurns that takes the array input and 1. Creates a hashtable called "hashT and inserts all the elements of the input array in the hashtable. 2. Finds pairs of clements in the hashtable whose sum is anather element (sum) in the hashtable and print the pairs in the console. 3. Returns anather hashtable names "sums af those sum elements For example: Input: [1,5,4,6,7,9 output: t6,5,7,91 Explanation: 6-1+5; 5-147-16;9-54 Class Tenplate irport java.util.HashSet public class FindSun t public static void nain(String args [] arr 1, 5, 4, 6, 7, 9 ) HashSet t HashSetInteger suns = new HashSet(); findsus (it[ clanants) // Initialize hashtable HashSotcIntogar> hashtable-now HashSatcIntegor) To add "newiten" to hashtable To check if "it exist in hashtable hashtableadd(newTtem) hashtable.contains(iten); return sums

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!