Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7006549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:29:31+00:00 2026-05-27T21:29:31+00:00

I need to compare between two int arrays of different size. It has to

  • 0

I need to compare between two int arrays of different size.

It has to be most efficient.

Is it possible to do in O(N * log(N)) time?

It should print integers that differ between the two arrays.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:29:32+00:00Added an answer on May 27, 2026 at 9:29 pm

    The algorithm is O(n), but you are assuming that the arrays are equally sized and each one has a size of ARY_SIZE.

    I will not solve the entire homework for you, but I suggest you start with the following function header: int compar2arr(int arrA[], int arrA_size, int arrB[], int arrB_size).

    Keep in mind that for function arguments int arrA[] is merely equivalent to int* arrA.

    As noted by Keith and Sebastian, arrA_size != arrB_size implies different (unless an author of the task defines it in other way). So you check it at the begining and return false if it holds.

    EDIT

    Ok, I re-read your post and it seems you need to just display all the not-equal elements and you do not know how to deal with the fact they are of different sizes.

    Therefore I suggest to start with the following:

    int compar2arr(int arrA[], int arrA_size, int arrB[], int arrB_size)
    {
       int smaller_size = // arrA_size or arrB size, the smaller one; 
       int higher_size = // arrA_size or arrB size, the higher one; 
       int *bigger_array;  
       int i;     
       int result = true;
    
       if (arrA_size > arrB_size)
           bigger_array = arrA;
       else
           bigger_array = arrB;
    
       for (i = 0; i < smaller_size; i++)
       {
          if (/* i-th elements are not(!!) equal */)
          {
             result = false;
             // print the values to be different
          }
       }
    
       if (smaller_size != higher_size)
         result = false;
    
       for (i = smaller_size; i < higher_size; i++)
       {
           // print bigger_array[i]
       }
    
       return result;
    }
    

    I am sure you can come up with the actual code to replace comments.
    It is not the most concise way to write, but wanted to keep it easy to understand. Anyway, the computational complexity is O(n), the best possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compare(finding remaining days and time between two days) using joda time.
How to compare the similarity between two arrays? Say I have: Base Array: [.5,0,0,0,.25,0,0,.25,0,0,0,0]
Trying to compare a given Time between two times to see if it's within
I want to find time difference between two date and then compare the difference
I need to compare particular content of 2 SQL tables located in different servers:
I need to compare two Unix timestamps and I'm having trouble with the math.
I need to compare two dictionary values if the types stored are equal, this
I need to compare dozens of fields in two objects (instances of the same
I need to compare two Date s (e.g. date1 and date2 ) and come
I need to compare a int value with a datetime in a SQLExpress table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.