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
Which memory will be suitable (a) to Run a software (b) to store a software permanently ?
Katena32 [7]

(a) To run a software => RAM

(b) To store a software => ROM

3 0
3 years ago
Only answer this question properly​
leonid [27]

Answer:

hi.......,.........

Explanation:

I wish it help you

Make me brainly

5 0
3 years ago
The values of the member variables of objectOne are being copied into the corresponding member variables of objectThree. This in
djyliett [7]

Answer:

member wise Initialization.

Explanation:

Member wise initialization is used for the following cases:-

  1. When you have constant member in your class.
  2. When you have Reference member in your class.
  3. When you have a very large member in your class.
  4. When you have a member with no default constructor.

Member wise initialization is uses initialization and the direct initialization uses assignment.

8 0
4 years ago
Imagine that you've properly connected your multimeter into an operating circuit, and the meter's function/range switch is set t
Free_Kalibri [48]
If the meter is set to  read DC voltage in the 20 volt range and it displays a 1 then it should mean 1 volt assuming that the maximum reading would be 20 volts at that setting. But if it is only around 1 volt is might be more accurate to set it at say 2V range to get say 1.6 actual volts.
8 0
3 years ago
Read 2 more answers
Select all True statements! Question 1 options: a) Host A is sending Host B a large file over a TCP connection. Assume Host B ha
VikaD [51]

<u>Solution:</u>

a)   False. Piggyback is used only for efficiency. If there's no data packet to be piggybacked to, then B will just send the acknowledgement packet.

b)  False. It is the size of the receiver's buffer that's never changed. RcvWindow is the part of the receiver's buffer that's changing all the time depending on the processing capability at the receiver's side and the network traffic.

c)  The given statement is True.

 d) False. The sequence number of the subsequent segment depends on the number of 8-byte characters in the current segment.

e)  True. Every TCP segment has a current value of rwnd in the receive window.

f)  False. Next_RTT = alpha * last_estimated_RTT + (1-alpha)*newly_collected_RTT_sample. In this case even though the last sampleRTT which is the newly_collected_RTT_sample is 1sec, the next_RTT still depends on alpha and last_estimated_RTT. Therefore, the next_RTT is not necessarily greater than 1sec.

g) False. The acknowledgement number has nothing to do with the sequence number. The ack. number indicates the next sequence number A is expecting from B.

5 0
4 years ago
Other questions:
  • Where is the typical location of a touchpad inside of a laptop?
    14·1 answer
  • The content of each content page that uses a master page is stored in the ________________ of the master page.
    6·1 answer
  • Where can you access all the formatting options for worksheet cells?
    5·1 answer
  • What is out put.what is data. what is microprocessor
    14·1 answer
  • Suppose you are consulting for a bank that's concerned about fraud detection, and they come to you with the following problem. T
    13·1 answer
  • The kings and queens of England are listed in a relation Kings(name,nickname,house,beginReign,endReign). Their name is unique, e
    8·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    10·1 answer
  • You've adjusted your bicycle seat so it's centimeters from the ground how high should your handlebars be
    10·2 answers
  • Which of the following is one of the tools used by a Python IDE that helps prevent syntax errors?
    9·1 answer
  • Which would you use to get the number of elements in a dictionary?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!