Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function named equivalentArrays that has two array arguments and returns 1 if the two arrays contain the same values ( but not necessarily
Write a function named equivalentArrays that has two array arguments and returns if the two arrays contain the same values but not necessarily in the same order otherwise it returns Your solution must not sort either array or a copy of either array! Also you must not modify either array, ie the values in the arrays upon return from the function must be the same as when the function was called. Note that the arrays do not have to have the same number of elements, they just have to have one of more copies of the same values.
If you are programming in Java, the function prototype is int equivalentArraysint a int a
Hint: If your solution compares the length of the first array with the length of the second array or vice versa, you have misunderstood the problem!! Your solution does not need to determine which array is bigger!
Examples:
if a is and a is return
because both arrays contain the values
because both arrays contain the values
because both arrays contain the values
because both arrays contain the values
because both arrays contain the values
the value is not in the first array
the value is not in the second array
the value is not in the first array
is not in the first array.
not possible to find a counterexample
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started