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
AysviL [449]
3 years ago
11

Suppose you have two arrays: Arr1 and Arr2. Arr1 will be sorted values. For each element v in Arr2, you need to write a pseudo c

ode that will print the number of elements in Arr1 that is less than or equal to v. For example: suppose you are given two arrays of size 5 and 3 respectively. 5 3 [size of the arrays] Arr1 = 1 3 5 7 9 Arr2 = 6 4 8 The output should be 3 2 4 Explanation: Firstly, you should search how many numbers are there in Arr1 which are less than 6. There are 1, 3, 5 which are less than 6 (total 3 numbers). Therefore, the answer for 6 will be 3. After that, you will do the same thing for 4 and 8 and output the corresponding answers which are 2 and 4. Your searching method should not take more than O (log n) time. Sample Input Sample Output 5 5 1 1 2 2 5 3 1 4 1 5 4 2 4 2 5
Engineering
1 answer:
brilliants [131]3 years ago
6 0

Answer:

The algorithm is as follows:

1. Declare Arr1 and Arr2

2. Get Input for Arr1 and Arr2

3. Initialize count to 0

4. For i in Arr2

4.1 For j in Arr1:

4.1.1 If i > j Then

4.1.1.1 count = count + 1

4.2 End j loop

4.3 Print count

4.4 count = 0

4.5 End i loop

5. End

Explanation:

This declares both arrays

1. Declare Arr1 and Arr2

This gets input for both arrays

2. Get Input for Arr1 and Arr2

This initializes count to 0

3. Initialize count to 0

This iterates through Arr2

4. For i in Arr2

This iterates through Arr1 (An inner loop)

4.1 For j in Arr1:

This checks if current element is greater than current element in Arr1

4.1.1 If i > j Then

If yes, count is incremented by 1

4.1.1.1 count = count + 1

This ends the inner loop

4.2 End j loop

Print count and set count to 0

<em>4.3 Print count</em>

<em>4.4 count = 0</em>

End the outer loop

4.5 End i loop

End the algorithm

5. End

You might be interested in
Derive the probability that a receptor is occupied by a ligand using a model that treats the L ligands in solution as distinguis
love history [14]

that is the same thing as you are not going through this week or something

7 0
3 years ago
Students are expected to respond to one of the two questions described below. Students should provide examples to clarify their
Flura [38]

Answer:

can u explain what we are answering?

Explanation:

7 0
4 years ago
What factors affect the temperature when vapor condenses
kati45 [8]

Answer:

Condensation

Explanation:

8 0
3 years ago
1. How many pieces of 12-1/2" long wood can be cut from a piece of
Pani-rosa [81]
B. If you do 39-3/4 divided by 12-1/2 you get 3.18
8 0
3 years ago
The rear window of an automobile is defogged by passingwarm air at 40ºC over its inner surface, and the associatedconvection coe
lora16 [44]

See attachment please.

Download docx
4 0
4 years ago
Other questions:
  • How long does it take to build a steam engine?
    10·1 answer
  • Turpentine flows through a 12-nominal schedule 40 pipe. What is the flow rate that corresponds to a Reynolds number of 2000?
    12·1 answer
  • A piston-cylinder device contains 0.1 [kg] of air at a pressure of 100 [kPa] and a temperature of 400 [K] that undergoes an expa
    14·1 answer
  • 2.9 A young engineer is asked to design a thermal protec- tion barrier for a sensitive electronic device that might be exposed t
    9·1 answer
  • Which statement best explains the underlined portion of the quote from the declaration of independence
    11·1 answer
  • An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Ove
    7·1 answer
  • Guys i need help and some ones please help me
    12·1 answer
  • Forcing a solid piece of heated aluminum through a die forms:
    15·2 answers
  • How can historical design elements be added to modern building plans?
    11·2 answers
  • A rod of length L is made of a material with thermal conductivity k, initially with a tem- perature distribution along its lengt
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!