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
sashaice [31]
3 years ago
15

Describe an algorithm that, given n integers in range 0 to k, preprocesses its input and then answers any query about how many o

f the n integers fall into a range [a...b] in O(1) time. Your algorithm should use O(n+k) preprocessing time.
Computers and Technology
1 answer:
pogonyaev3 years ago
8 0

Answer:

Explanation:

Assume that our integers are stored in array A[1 · · · n] and thus, length[A] = n. We need two additional  arrays B[1 · · · k] and C[1 · · · k].

Our algorithm will first initialize all elements of array B to 0. This step

requires O(k) time.

Next, for each element of array A (i.e., A[i] for i = 1, 2, · · · , n), we will increment

B[A[i]]. Observe that this step will require O(n) time and B[j] for j = 1, 2, · · · , k, now contains the number

of elements of A having value j. Finally, make C[1] = B[1] and for each element l of array C where

l = 2, 3, · · · , k, we will compute C[l] = B[l] + B[l − 1]. This step takes O(k) time.

Now, to answer any query about how many of n integers fall into a range [a · · · b], we simply compute

C[b] − C[a] + B[a].

Observe that this computation requires only O(1) time after the O(n + k) preprocessing

time.

You might be interested in
Which of the following IS true about usnig the Hatch command ?
xeze [42]

Answer:

What is the following?

Explanation:

There is no following listed, so I can't help you.

6 0
3 years ago
Since the 1970s, local tv newscasts have developed a similar look. that's because
professor190 [17]
<span>(news doctors, consultants) said people should be young, attractive, smile and look happy.</span>
6 0
4 years ago
Which of the following syntaxes displays a dialog box, causing the user to enter input text?
maks197457 [2]

Answer:

c. prompt(text[,default Input])

Explanation:

In javaScript the prompt() method displays a dialog box which allows the user input text required by the program.

5 0
3 years ago
Why might you add the Outer Glow effect to text?
-Dominant- [34]

Answer:

nothing it's perfect in the way it is

Explanation:

4 0
3 years ago
• Ethernet network that connects a single client PC to a single server and label the locations of switches and transmission link
OLEGan [10]

In the network constructed, we need to use 3 switches to  be able to connect a single client PC to the single server. Therefore:

  • Connect server to switch 1        (225 m)
  • Connect switch 1 to switch 2     (225 m)
  • Connect switch 2 to switch 3    (225 m)
  • Connect switch 3 to client PC   (225 m)

<h3>What is the network about?</h3>

The maximum distance for ethernet connection is known to be about 100 meters and it is one that is often used in the transmission speeds.

Note that when one has added to the network switches, the distance need to be increased to about 200 meters and thus about 900 meters of distance need to exist between the client PC and the server.

The Ethernet network need to be designed as:

Connect server to switch 1        (225 m)

Connect switch 1 to switch 2     (225 m)

Connect switch 2 to switch 3    (225 m)

Connect switch 3 to client PC   (225 m)

Note that Total distance covered = 225 + 225 + 225 + 225

                                                       = 900 meters

Therefore, In the network constructed, we need to use 3 switches to  be able to connect a single client PC to the single server.

Learn more about Ethernet from

brainly.com/question/16947988

#SPJ1

6 0
1 year ago
Other questions:
  • Dfd symbols are referenced by using all ____ letters for the symbol name.
    9·1 answer
  • 7.12 LAB: Contains the character
    12·2 answers
  • Switches operate on what layer of the OSI Model
    11·1 answer
  • If it is impractical to place guest users in a secure network, isolated from the production network by firewall barriers, then:
    14·1 answer
  • What is anatomy of software house?
    10·1 answer
  • Which wireless communication technology is most likely used when synchronizing device information to an automobile?
    14·1 answer
  • Information from the system that is used to make modifications in the input, processing actions, or outputs is referred to as: G
    9·2 answers
  • A virus is a self-replicating program that produces its own code by attaching copies of it into other executable codes.
    7·1 answer
  • Whats the answer to this question?
    7·1 answer
  • Write a program that has the user input how many classes they are taking this semester and then output how many hours they will
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!