Sale!

Programming HW-5 CSL2020 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (4 votes)

1. Read two arrays A and B from the command line. You can assume that the input is given in two
separate lines and the format of each line is as follows:
N, x1, x2, …, xN
Here, N is the number of elements and this is followed by the actual numbers. Further, all the numbers
are positive integers.
Using hashing techniques we studied in the class, create two new arrays C and D such that:
(i) C contains numbers only in A or in B (symmetric difference) [2 Marks]
(ii) D contains numbers in both A and in B (intersection). [2 Marks]
Print C and D on separate lines.
Your algorithm should run in linear time.
2. Read an array A from the command line just like the previous question. Then read a number k from
the command line. Write a program to find two numbers x and y in A such that x+y = k. If no such pair
can be found then print “Not found”. [2 Marks]
Your algorithm should run in linear time.