Question: (java) 1. An Array A contains n-1 unique integers in the range [0,n-1] , that is , there is one number from this range that
(java)
1. 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) algorithm for finding that number. You are allowed to use only O(1) additional space besides the array A itself
(DO NOT SORT THE ARRAY. Must provide a test application with at least 2 sets of numbers. Hint: find smallest, largest, and sum. Compare the sum with the series summation.)
2. Write a short recursive Java method that takes a character string s and outputs its reverse. For example, the reverse of 'pots&pans' would be 'snap&stop'.
(ASSUME STRINGS WITH NO PUNCTUATION OR SPACES. The test application should print the original string in reverse besides testing for palindrome. Hint: can use textbook example for reversing elements of an array on page 208.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
