Question: Q2) Give a recursive algorithm to compute the product of two positive integers m and n using only additions. You need to write the algorithm

 Q2) Give a recursive algorithm to compute the product of two

Q2) Give a recursive algorithm to compute the product of two positive integers m and n using only additions. You need to write the algorithm in pseudo-code. (5 marks) Q3) An array A contains n1 unique integers in the range [0, n1], that is there is one number from this range that is not in A. Design an O(n) time algorithm for finding that number. You are allowed to use only O(1) additional space besides the array A itself. (5 marks) Q4) suppose you are given an array, A, containing n numbers in order. Describe in pseudocode an efficient algorithm for reversing the order of the numbers in A using a single for-loop that indexes through the cells of A, to insert each element into a queue, and then another for-loop that removes the elements from the queue and puts them back into A in reverse order. What is the running time of this algorithm

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!