answer.
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
Softa [21]
2 years ago
11

Assume the array of integers values has been created. Which condition must be used in the indicated area so the loop below will

assign max the largest value in values? int max = values[0]; for (int val: values) { if (/* Put condition here */) max = val; }
Computers and Technology
1 answer:
scZoUnD [109]2 years ago
7 0

Answer:

val > max

Explanation:

Assuming the values array is already created, inside the loop, we need to check if the val, a value in the values array, is greater than max. If it is greater than the max, that means it is our new max. Then we would set the max as the val. This way, if there is any value greater than max, it will be our max at the end of the loop.

You might be interested in
Suppose that each row of an n×n array A consists of 1’s and 0’s such that, in any row i of A, all the 1’s come before any 0’s in
Anna71 [15]

Answer:

Check the explanation

Explanation:

  •    Each row of nxn array A consists of 1’s and 0’s such that , in any row of A, all the 1’s come before any 0’s in that row.
  •    Use binary search algorithm to find the index of the last 1 in a row.
  •    Perform this process for each row.
  •    Now, searching for last occurrence of 1 in a row will take O (log n) time.
  •    There are n such rows, therefore total time will be O (n log n).

Complexity analysis:

   The method would be to use binary search for each row to find the first zero starting with index of A[i][n/2+1].

   Let’s say j=n/2.

   The number of 1’s in a row would be j+1.

   This would take O (log n).

   An algorithm that divides by 2 until the number gets sufficiently small then it terminates in O (log n) steps.

   As there are n rows the complexity would be O (n log n).

Pseudo-code:

A = [[1,0,0,0],[0,0,0,0],[1,1,1,1],[1,1,0,0]]

n=4

c=0

for i in range(n): # Loop in rows

  j = n/2 # Search from middle index

  while j>0: # Loop in column

      if(A[i][j]==0): # search for first zero

          if(A[i][j-1]==1): # confirm first zero

              c = c+j # add 1's count to c

              break

          else: # reduce index by 1 or j/2

              if(j/2 == 0):

                  j = j-1

              else:

                  j = j - j/2

      else: # increase index by 1 or j/2

      if(j/2 == 0):

      j = j+1

      else:

          j = j + j/2

      if(j==n): # For all 1's

      c = c+n

      break  

print c

8 0
2 years ago
In this problem, we want to compare the computational performance of symmetric and asymmetric algorithms. Assume a fast public-k
MariettaO [177]

Answer:

The AES decryption time is 8 minutes

Explanation:

GIVEN THAT:

The 1 GByte is equal to 230 bytes and equal to 233 bits

The RSA decryption time is calculated as = 233 / (100*230 )

= 83886. 06 seconds

= 23 hours

The RSA decryption time is 23 hours

The AES decryption time is calculated as = 233 / (17 * 230 )

= 481.81 seconds

= 8 minutes .

The AES decryption time is 8 minutes

4 0
2 years ago
FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
Sholpan [36]

Answer:

Transmission Control Protocol (TCP)

Explanation:

FTP: FTP stand for File Transfer Protocol. It is an internet protocol for transferring files between computers on a computer network over TCP/IP connections. It is based on client server architecture in which a client asks for a file and the server (local or remote) sends it. FTP uses TCP to ensure all the data packets are transmitted correctly to the proper destination.

Transmission Control Protocol: It is a protocol used in the Transport Layer of the TCP/IP model. The basic role of this layer is to ensure end-to-end delivery of data from the source to the destination. TCP is a connection oriented protocol that works with the Internet Protocol and provides ordered, guaranteed and error free delivery of data from source to destination. This is how application programs communicate and exchange data through an IP network. It is connection oriented protocol means connection between client and server is setup before data transmission. At source host TCP divides streams of bytes in segments. Then it allocates sequence number to each segment. At destination end it reorders the delivered segments. Then it sends an acknowledgment  to sender as a signal that the correct segments have been received. TCP also employs error detection that ensure reliability. TCP also manages flow control and congestion control to avoid data packets loss or delay and to ensure that a sender does not send packets faster than the receiver can receive.

4 0
2 years ago
Write the definition of a function dashedline, with one parameter , an int . if the parameter is negative or zero, the function
GalinKa [24]
Static void DashedLine(int n){     if (n>1) Console.WriteLine(new String('-', n));}
5 0
2 years ago
Templates contain common layout and formatting that can save you time by not having to recreate documents from scratch. True or
Anarel [89]
True because i had heard my friend doing her homework and i was helping her study
4 0
2 years ago
Other questions:
  • Computer design software requires __________________ to be used properly and successfully by architects.
    9·2 answers
  • Sharon reads two different articles about avocados. The first article, in a weight loss magazine, claims that avocados are unhea
    10·2 answers
  • In 2–3 sentences, describe how you would change the background of a group of cell
    6·2 answers
  • Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
    11·1 answer
  • #Remember that Fibonacci's sequence is a sequence of numbers
    14·1 answer
  • Initialize a list. ACTIVITY Initialize the list short.names with strings 'Gus', Bob, and 'Ann'. Sample output for the given prog
    9·1 answer
  • array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting o
    11·1 answer
  • 15) The codes for class Hotel has been defined in two separate files Hotel.h, and Hotel.cpp. Which of the following statements i
    12·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • A company decides to relocate its operations to another state in order to take advantage of some new business investment credits
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!