1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AnnyKZ [126]
1 year ago
10

which one of the following will reach every element in the array a? 1. for(int i = 0; i <= a.length; i++) 2. for(int i = 0; i

< a.length; i++) 3. for(int i = 1; i <= a.length; i++) 4. for(int i= 1-1 ; i < a.length; i++)
Computers and Technology
1 answer:
andrey2020 [161]1 year ago
4 0

Answer:

You can simplify the problem down by recognizing that you just need to keep track of the integers you've seen in array that your given. You also need to account for edge cases for when the array is empty or the value you get would be greater than your max allowed value. Finally, you need to ensure O(n) complexity, you can't keep looping for every value you come across. This is where the boolean array comes in handy. See below -

public static int solution(int[] A)

{

int min = 1;

int max = 100000;

boolean[] vals = new boolean[max+1];

if(A.length == 0)

return min;

//mark the vals array with the integers we have seen in the A[]

for(int i = 0; i < A.length; i++)

{

if(A[i] < max + 1)

vals[A[i]] = true;

}

//start at our min val and loop until we come across a value we have not seen in A[]

for (int i = 1; i < max; i++)

{

if(vals[i] && min == i)

min++;

else if(!vals[i])

break;

}

if(min > max)

return max;

return min;

}

You might be interested in
_ is the use of a collection of computers, often owned by many people or different organizations, to work in a coordinated manne
ddd [48]

Answer:

"Grid computing" is the correct answer for the above question.

Explanation:

  • Grid computing is a process in which many computers are participating to solve a single problem. This type of process is distributed multiple computers to perform a different type of task.
  • If there is large problem and if many computers solve that problem, then that problem is solved easily within a few minutes.
  • This is because many computers are working for that problem.
  • The above question asked about that process in which many computers are working to solve a single problem. This processor is known as "Grid Computing".
8 0
3 years ago
I - For any two points on the Internet, there exists only one path between the two points II - Routing on the Internet is fault
sukhopar [10]

Answer:

I - False

II -True

Explanation:

For any communication between two points on the Internet, routing is to choose an optimum path.

But routing is also fault tolerant and redundant, which means that there are <em>alternative</em> paths to deal with possible problems and provide security during transmission.

4 0
3 years ago
Which of the following is true about file formats?
statuscvo [17]

Answer:

A

Explanation:

The answer is A mate, if you need any help let me know please

3 0
3 years ago
Read 2 more answers
Points on how will successfully submit quizzes in ICT correctly?
jeka94

Answer:

I am sorry but I don't understand your question. Can you edit it and explain it more briefly?

Explanation:

6 0
3 years ago
Which is considered both an input and output device?
Marina86 [1]

Answer:

speaker

Explanation:

its the one that gives sounds

6 0
2 years ago
Read 2 more answers
Other questions:
  • Test if a password entered is correct. The secret phrase is Ada Lovelace. Sample Run 1 Enter the Password: Ada Lovelace Sample O
    13·1 answer
  • Drivers dealing with strong emotions may take risks they otherwise would not. <br> true false
    15·1 answer
  • What type of firewall works on the Session layer that creates a connection and allows packets to flow between the two hosts with
    8·1 answer
  • Oxnard Casualty wants to ensure that their e-mail server has 99.98 percent reliability. They will use several independent server
    14·1 answer
  • To save a file so that it can be opened on most computers, select the ____ option.
    10·2 answers
  • Which shortcut key aligns text to the center of the paige
    5·1 answer
  • How many bytes does a common processor require to represent an integer?
    7·1 answer
  • Next, let's examine what happens when you apply a style to an element that contains other elements. The body element in the HTML
    12·1 answer
  • Plz help
    14·2 answers
  • Three types of query​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!