Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new file called scrambled.c, containing a single function that matches this declaration: int scrambled( unsigned int arr1[], unsigned int arr2[], unsigned int len
- Create a new file called scrambled.c, containing a single function that matches this declaration:
int scrambled( unsigned int arr1[], unsigned int arr2[], unsigned int len );
- Arrays arr1 and arr2 are both of length len, and contain values in the range [0 .. 99] inclusive, only.
- The function scrambled() should return 1 iff arrays arr1 and arr2 contain the same values in any order, or 0 otherwise.
- len can have any unsigned int value, including 0.
- If len is 0 then scrambled() should return 1 (since the arrays have the same - empty - contents).
- You must not change the contents of the arrays.
- Use an algorithm that has run time linear in the array length n. Note that this means you can not sort the arrays since that can not be done in linear time.
Examples of arrays for which scrambled should return 1:
- arr1 = {10,15,20}, arr2 = {10,15,20}
- arr1 = {99}, arr2 = {99}
- arr1 = {1,2,3,4,5}, arr2 = {5,3,4,2,1}
- arr1 = {}, arr2 = {} (i.e. len = 0)
- arr1 = {2,1,3,4,5}, arr2 = {1,2,4,3,5}
Examples of arrays for which scrambled should return 0:
- arr1 = {1,1}, arr2 = {1,2}
- arr1 = {10,15,20}, arr2 = {10,15,21}
- arr1 = {1,2,3,4,5}, arr2 = {5,3,4,2,2}
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