Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please make sure it's O(n). Try to take screenshots of the code so I can see the indentations. If it's good, I will give thumbs
Please make sure it's O(n). Try to take screenshots of the code so I can see the indentations. If it's good, I will give thumbs up 100%. Thanks.
4. Scrambled Here is a programming puzzle that you might find in the real world. It requires conditionals, loops and arrays. There is a simple O(n) algorithm to solve the problem (.e. you do not need to sort anything). Requirements 1. 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); 2. Arrays arri and arr2 are both of length len, and contain values in the range [0 .. 99] inclusive, only. 3. The function scrambled() should return 1 iff arrays arrl and arr2 contain the same values in any order, or 0 otherwise. 4. len can have any unsigned int value, including 0. 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. 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) Example of a program that uses your function: 1. #includeStep 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