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 6659063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:59:14+00:00 2026-05-26T01:59:14+00:00

There are three arrays a1, a2, a3 of size n. Function searches for common

  • 0

There are three arrays a1, a2, a3 of size n. Function searches for common number in these arrays.
Algorithm is the next:

foreach n in a1
    if n is found in a2
        if n is found in a3
            return true

return false

My guess that worse case will be the next: a1 and a2 are equal, a3 does not contain any common number with a1.

Complexity to iterate through array a1 will be O(i).
Complexity to search array a2 or a3 is f(n) (we do not know how they are searched).
My guess that overall complexity for worse case would be:

O(n) = n * f(n) * f(n) = n * (f(n))^2

I was told that that it is wrong.
What is correct answer then?

  • 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-26T01:59:15+00:00Added an answer on May 26, 2026 at 1:59 am
    n * f(n) * f(n) = n * (f(n))^2 
    

    I was told that that it is wrong. What is correct answer then?

    The correct answer for the given algorithm:

    n * (f(n) + f(n)) = O(n*f(n))
    

    You don’t search a3 array f(n) times for each n in a1 so you should use + instead of *.

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

Sidebar

Related Questions

I have three arrays, all the same size: xout % cell array xin %
I come from a php background and in php, there is an array_size() function
I heard that there is a hard limit on the size of .Net Array
I have three arrays (it's written in C but that is not important, it
I have the following three arrays and need to create a new two-dimensional array
I'd like to merge three arrays like this: $a = array(1,2,3,4); $b = array(5,6,7,8);
I want to do permutation in Perl. For example I have three arrays: [big,
I'm simplifying a larger complex problem with the following... Given three arrays of integers,
I would like to find out safe ways of implementing three dimensional arrays of
Given the array, i need to find how many monotonically increasing Sub-arrays there are

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.