Question: ALL FUNCTIONS IN JAVA AND IN ONE FILE PLEASE Problem 1: Suppose that each row of an n n array A consists of 1s and
ALL FUNCTIONS IN JAVA AND IN ONE FILE PLEASE
Problem 1: Suppose that each row of an n n array A consists of 1s and 0s such that, in any row of A, all the 1s come before any 0s in that row. Write a Python function or Java method for finding the row of A that contains the most 1s.
Problem 2: Write a recursive Python function or Java method to compute the product of two positive integers m and n using only addition.
Problem 3: An array A contains n 1 unique integers in the range [0, n 1]; that is, there is one number from this range that is not in A. Design an O(n)-time algorithm (write Python function or Java method) for finding that number. You are allowed to use only O(1) additional space besides the array A itself.
Problem 4: Write a recursive Python function or Java method for finding both the minimum and the maximum elements in an array A of n elements. Your method should return a pair (a, b), where a is the minimum element and b is the maximum. What is the running time of your method?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
