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
Why do mosquitoes lay eggs in water​
d1i1m1o1n [39]

Answer: Some species of mosquitoes lay their eggs on water or on vegetation very near to water because their larval instars are aquatic. Thus, when the eggs hatch the first instar larvae will already be in the larval media. Some species of Aedes mosquitoes lay their drought resistant eggs on the soil of dried up playa lake beds. When it rains, the moisture will serve as a hatching stimulus and the eggs will hatch and spend their larval instars in the pools of rainfall. Other mosquito female will lay their eggs in the water of plant axils, tree holes and related plant habitats. In each of these instances, the immature mosquito instars require water in larval development and molt into adult insects.

hope it helps you

3 0
3 years ago
Read 2 more answers
Critique and rank four different brands of antivirus software, rating them by price, functionality, and system requirements. Pre
scoundrel [369]

Answer:

Explanation:yes it's true bc you need to order them bye what they are and hope this is right of it isn't I'm truly sorry

5 0
3 years ago
Select the correct text in the passage. Idenufy the phrase that shows the use of a non-contact-type temperature sensor. Jim work
suter [353]

Answer:

where he is allowed only to enter on successful biometric verification by sensor at the gate,,it shows to some extent there is no contact,,,the molten we are told is risky so there should be no close contact with it,,

5 0
3 years ago
The primary tool for representing a system's component processes and the flow of data between them is the: A. data flow diagram.
Ber [7]

Answer:

Option A i.e., Data flow diagram.

Explanation:

The data flow diagram illustrates that details travel into a mechanism or mechanism. This requires getting information as well as print it, information warehouses, as well as the different subprograms by which the information travels.

So, The primary device for describing the device's function as well as the transfer of information with them is the data flow diagram.

  • Option B is incorrect because it offers a detailed reference for interpreting as well as using the details.
  • Option C is incorrect because it applies to the goods or services documents given to end consumers.
  • Option D is incorrect because It's used to define specifications with a procedure on the data flow diagram.
7 0
4 years ago
Answer all 1).The most common layout of keys on the keyboard is the _____ keyboard. ASDF QWERTY JKL QWOPY,
Anna11 [10]

1. The most common layout of keys on the keyboard is the  QWERTY keyboard

A computer keyboard is an input device that is used to key in letters, numbers, and other symbols The computer user uses the key board to as a mode of communication between him/her and the commuter in order to produce the expected results as the output.

Qwerty keyboard is the  most common layout of keys on the keyboard.It is the standard computer keyboard and it refers to the first six letters on the upper row of the keyboard.

2. The pinky finger on the right hand types ; P 0 ' / [ ]

The Pinky Finger is the little or the small finger which is below or next to the small finger. On the computer keyboard the pinky finger types P, semicolon (;), colon (:), slash (/), question mark (?), enter, backspace and  shift

3.The second finger on the left hand types 3 E D C

The second left finger is also known as  the the index finger or the the pointer finger. When it comes to typing on the computer keyboard, the second finger on he left hand of the computer user is used to type or to input the characters 3ECD.

4.Which finger presses the H key on the keyboard? index finger on the right hand

The index finger on the right hand also known as  the pointer is the finger used by the computer user to key in the character H . It is located between the first and third fingers, between the thumb and the middle finger.  

5.The QWERTY keyboard is the most common layout of keys on a keyboard. TRUE

Qwerty keyboard is the  most common layout of keys on the keyboard.It is the standard computer keyboard and it refers to the first six letters on the upper row of the keyboard.


6..If you were practicing keyboarding and the exercise contained the letters, s, w, e, z, r, v, and t, what section of the keyboard are you practicing?  

The computer keyboard is is as the input device is divided into different sections which are the lower, upper, left and the right sections.

The LEFT section contains the letters s,w,e,z,r,v and t.

7. To improve at keyboarding ,it is a good idea to master  frequently the typed words TRUE

It is good to practice the most frequently on the used keys and the key combination.This helps one to improve on his/her typing skills.This is also so helpful because the faster you type the more you will be able to communicate with others and also be able to do the preferred job.

8.To improve your keyboarding skills, you should practice typing the most frequently used keys and key combinations

Practicing on typing skills helps to make you more productive .It also helps one to improve and also increase accuracy and decoding efficiency as well.This will also help the user to avoid the very many mistakes and also have a good progress in his/her work.


3 0
4 years ago
Read 2 more answers
Other questions:
  • Which of the following statements is​ FALSE? A. Security is a huge concern for nearly all organizations with private or propriet
    14·1 answer
  • What i have to care about transmitting data packet from one controller to other controller?
    8·1 answer
  • Who should be in charge of designing the database – team members, who understand the application requirements, or a database des
    11·1 answer
  • Which of the following is a true statement about the countries highlighted on the map?
    10·2 answers
  • To answer the research question "How am I going to find the information I need on the tople?" the best thing Georgia should
    15·1 answer
  • Design state machines to control the minutes and hours of a standard 24 hour clock. Your clock should include an AM/PM indicator
    11·1 answer
  • If we ignore the audio data in a video file, a video file is just a collection of many individual frames (i.e., images). What is
    6·1 answer
  • Help ASAP please This is a skills lab simulation for college, it’s on Microsoft word is there a keyboard shortcut or something o
    12·1 answer
  • What is your favorite anime?
    11·1 answer
  • Taking this driver education course
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!