Answered step by step
Verified Expert Solution
Link Copied!

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

  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 arr1 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 arr1 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}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

More Books

Students also viewed these Databases questions