Question: Ques) write a program in c which meets the following requirements. Requirements 1. Create a new file called scrambled.c, containing a single function that matches

Ques) write a program in c which meets the following requirements.

Ques) write a program in c which meets the following requirements. Requirements

Requirements 1. Create a new file called scrambled.c, containing a single function that matches this declaration int scrambled unsigned int a,unsigned int bl, unsigned int len 2. Arrays a and b are both of length len, and contain values in the range [O.. 99] inclusive, only 3. The function scrambled () should return 1 iff arrays a and b contain the same values in any order, or 0 otherwise 4. len can have any unsigned int value, including O 5. If len is 0 then scrambled() should return 1 (since the arrays have the same empty - contents) 6. You must not change the contents of the arrays. 7. 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 xamples of arrays for which scrambled should return 1 a 10,15,20), b 10,15,20) a (99), b - 199) a 1,2,3,4,5), b (5,3,4,2,1) a (2,1,3,4,5), b 1,2,4,3,5) Examples of arrays for which scrambled should return 0 a- 1,1), b 1,2) a=(10.15.20), b=(10.15.21) a 1,2,3,4,5), b-5,3,4,2,2) . Example of a program that uses your function 1. #include 2. // declaration of function implemented in scrambled.c 3. int scrambled( unsigned int a[], unsigned int bll, unsigned int len) 5. int main( void) 7 unsigned int a[31-(10, 15, 20; 8 unsigned int b[3] 110, 20, 15; 10. if ( scrambled 11.i 12 13. else a, b, 3) printf( "b is a scrambled version of aln" printf( "b has different contents to aln" 15.> 16. 17.return 0; 18 Hint The number of different values you see is known and quite small Testing and submission You should write your own test program with a main() function, using the example above as a guide. To reiterate: you must not submit a complete program though you will need to write one to test your function yourself. You must submit a single file containing a single function When your function works, add and commit only the file scrambled.c to the repo git add scrambled.c $ git commit -m "scrambled is working" $ git push

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!