Question: 4b) b) Design an algorithm in pseudocode (or any programming language of your choice) that, given any array A of n integers, returns 1 if

4b)

4b) b) Design an algorithm in pseudocode (or any programming language of

b) Design an algorithm in pseudocode (or any programming language of your choice) that, given any array A of n integers, returns 1 if there are A[i] and A[j] in A such that A[i]+A[j]=0; otherwise, the algorithm returns 0 . Your algorithm must not change the given array and may only use a constant amount of additional space. (4 marks) What is the time complexity of your algorithm in terms of O notation? (1 mark) Now suppose the algorithm may change the array and use any amount of additional space. Describe an algorithm for this problem (without giving any code) that would run significantly faster than your original algorithm. What is the time complexity of this algorithm? (4 marks)

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!