Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. [10 marks] We now modify the problem in Question 2 slightly by not requiring i,j and k to be distinct. More precisely, the output
3. [10 marks] We now modify the problem in Question 2 slightly by not requiring i,j and k to be distinct. More precisely, the output of the algorithm is'yes" if there exist three indices i, j and k, with 1-i, j, K-n, such that Ali] + AIj] + A t, and "no" otherwise For example, if AI1..7]-[28,-70,-23, 92, 56,-33,-77 and t--173, the answer would be "ves". because if we set i - 2 , 1-2, and k = 6, we have A[i1+ALj1+Akl 70-70-33 =-173 (a) [5 marks] Use the algorithm design paradigm of "reduce to known problem" to give an algorithm solution that uses (n2 lg n) time. (Hint: compute the following two sets of num bers: one set contains all possible values of A + A and the other set contains all possible values of t - A[k]) (b) [5 marks] Further give an O(n2)-time algorithm
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started