Question: PLEASE HELP WITH THE FOLLOWING PROBLEM 2 (20 points) a. Consider a list L of N integers. (1) Describe a brute-force algorithm that will count
PLEASE HELP WITH THE FOLLOWING PROBLEM

2 (20 points) a. Consider a list L of N integers. (1) Describe a brute-force algorithm that will count the number of pairs of integers in L that add to 0. (e.g. In the list [-1,2, 4, -4, 1,2], there are 2 pairs of numbers, (-1,1) and (4, -4), that add to 0.) (2) Give a tight upper bound for the runtime of your algorithm in terms of N using Big-Oh notation, and explain your analysis. b. Now consider a list L of N integers that are sorted from least to great- est. Describe an algorithm that will count the number of pairs of integers in L that add to 0, and analyze the runtime of the new algorithm by giving a tight upper bound in big-Oh notation and cxplaining how you got it. You may assume a binary search function bin.Search(A, r), which returns the index of
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
