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]
2 years 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]2 years 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 electricity a force or energy?
nevsk [136]

Answer:

Explanation:

Electrical energy is a form of energy resulting from the flow of electric charge. Energy is the ability to do work or apply force to move an object. In the case of electrical energy, the force is electrical attraction or repulsion between charged particles

6 0
1 year ago
Which sentence best describes an activity stream?
Masja [62]

I believe the answer you are looking for is C. :)

8 0
4 years ago
Read 2 more answers
The 10 IISSCC _____ cover 17 NIST control _____ which are arranged in three _____ called management, operational, and technical.
almond37 [142]

Answer:

Controls, families, domain

Explanation:

ISSCC means international information systems security certification consortium.

They are also known as ISC square, they offer two security certification the cissp and sccp.

7 0
3 years ago
Read 2 more answers
The trim video feature allows you to trim your clip by time measurements that are accurate to ____ of a second.
grigory [225]
The trim video feature allows you to trim your clip by time measurements that are accurate to one-thousandth of a second.  An example would be the P<span>owerPoint's </span>Trim Video feature which allows you<span> to </span>trim<span> the beginning and end of </span>your clip<span> by designating </span>your<span> desired Start </span>Time<span> and End </span>Time. These precise time measurements<span> are </span>accurate<span> to </span>one-thousandth<span> of a </span>second<span>.</span>
3 0
3 years ago
Which layer abstracts away the need for any other layers to care about what hardware is in use?
Vlad1618 [11]

Answer:

data link layer

Explanation:

you answer is data link layer

3 0
2 years ago
Other questions:
  • When desktop publishing software can interact with another software program, the two are said to
    6·1 answer
  • Someone help me I don’t know what to do /COMPUTER SCIENCE
    5·1 answer
  • What is used to monitor the activity of a network and notify network administrators when it identifies something as suspicious?
    15·1 answer
  • Which html attributes are required in the image () element - check as many as apply
    9·1 answer
  • A certain computer game is played between a human player and a computer-controlled player. Every time the computer-controlled pl
    8·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    13·2 answers
  • Look at (d), is it accurate? ​
    9·2 answers
  • As computer words get larger and larger, there is a law of diminishing returns: the speed of execution of real application progr
    8·1 answer
  • Define each of the following data mining functionalities: characterization, discrimination, association and correlation analysis
    9·1 answer
  • Write the names of different types of communication.​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!