Question: Algorithm UniqueElements (A[0 n-1) //Check whether all the elements in a given array are distinct //Input: an array A[1 n] //Output: returns true if all
Algorithm UniqueElements (A[0 n-1)
//Check whether all the elements in a given array are distinct
//Input: an array A[1 n]
//Output: returns true if all the elements in A are distinct and false otherwise
for i 0 to n - 2 do
for j i + 1 to n - 1 do
If A[i] = A[j] return false
return true
Be sure to do in Java.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
