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
Daniel [21]
3 years ago
15

Half of the integers stored in the array data are positive, and half are negative. Determine the

Computers and Technology
1 answer:
jonny [76]3 years ago
7 0

Answer:

Check the explanation

Explanation:

Below is the approx assembly code for above `for loop` :-

1). mov ecx, 0

2). loop_start :

3).    cmp ecx, ARRAY_LENGTH

4).    jge loop_end

5).    mv temp_a, array[ecx]

6).    cmp temp_a, 0

7).    branch on nge

8).        mv array[ecx], temp_a*2

9).   add ecx, 1

10).   jmp loop_start

11). loop_end :

Assumptions :-

*ARRAY_LENGTH is register with value 1000000

*temp_a is a register

Frequency of statements :-

1) will be executed one time

3) will be executed 1000000 times

4) will be executed 1000000 times

5) will be executed 1000000 times

6) will be executed 1000000 times

7) `nge` will be executed 1000000 times, branch will be executed 500000 times

8) will be executed 500000 times

9) will be executed 1000000 times

10) will be executed 1000000 times

Cost of statements :-

1) 10 ns

3) 10ns + 10ns + 10ns [for two register accesses and one cmp]

4) 10ns [for jge ]

5) 10ns + 100ns + 10ns [10ns for register access `ecx`, 100ns for memory access `array[ecx]`, 10ns for mv]

6) 10ns + 10ns [10ns for register_access `temp_a`, 10ns for mv]

7) 10ns for nge, 10ns for branch

8) 30ns + 110ns + 10ns

10ns + 10ns + 10ns for temp_a*2 [10ns for moving 2 into a register, 10ns for multiplication],

110ns for array[ecx],

10ns for mv

9) 10ns for add, 10ns for `ecx` register access

10) 10ns for jmp

Total time taken = sum of (frequency x cost) of all the statements

1) 10*1

3) 30 * 1000000

4) 10 * 1000000

5) 120 * 1000000

6) 20 * 1000000

7) (10 * 500000) + (10 * 1000000)

8) 150 * 500000

9) 20 * 1000000

10) 10 * 1000000

Sum up all the above costs, you will get the answer.

It will equate to 0.175 seconds

You might be interested in
Why was unicode invented
GrogVix [38]
The old system, ASII, was no where near large enough to deal with all the different languages & symbols that exist  
5 0
3 years ago
Read 2 more answers
Which of the following cannot be copyrighted
denpristay [2]
1.I'm not sure.
<span>2. A story that you wrote based on a book you read
3. T</span><span>he website user (I think)</span>
4 0
4 years ago
True or False <br><br> MAC addresses are assigned by the router along with your IP address.
Oduvanchick [21]
True. If you look at the router it will correspond with your MAC address
4 0
3 years ago
Which of the following is NOT a type of software?
natta225 [31]

Answer:

Output device

Explanation:

Im pretty sure that correct

3 0
4 years ago
Assume that an O(log2N) algorithm runs for 10 milliseconds when the input size (N) is 32. What input size makes the algorithm ru
NARA [144]

Answer:

An input size of N = 128 makes the algorithm run for 14 milliseconds

Explanation:

O(log2N)

This means that the running time for an algorithm of length N is given by:

F(N) = c\log_{2}{N}

In which C is a constant.

Runs for 10 milliseconds when the input size (N) is 32.

This means that F(32) = 10

So

F(N) = c\log_{2}{N}

10 = c\log_{2}{32}

Since 2^5 = 32, \log_{2}{32} = 5

Then

5c = 10

c = \frac{10}{5}

c = 2

Thus:

F(N) = 2\log_{2}{N}

What input size makes the algorithm run for 14 milliseconds

N for which F(N) = 14. So

F(N) = 2\log_{2}{N}

14 = 2\log_{2}{N}

\log_{2}{N} = 7

2^{\log_{2}{N}} = 2^7

N = 128

An input size of N = 128 makes the algorithm run for 14 milliseconds

5 0
3 years ago
Other questions:
  • Considers the assets of all things in an environment, and refers to the layering of security tools and methods often varying num
    13·1 answer
  • Create a file with a 20 lines of text and name it "lines.txt". Write a program to read this a file "lines.txt" and write the tex
    12·1 answer
  • To find the largest number in a list of numbers, use the _____.
    8·1 answer
  • The power we use at home has a frequency of 60 HZ. What is the time period of such a power?
    10·1 answer
  • Which of the following C++ statements displays a random number in the range 1 through 10?
    12·1 answer
  • List three things that scientists learned about earth beginning in the 1800s
    13·1 answer
  • What the best option if you cant show your PowerPoint presentation at all
    6·2 answers
  • What technology is being used instead of Adobe flash player​
    8·1 answer
  • When designing code, which of the following best describes the purpose of a Post Mortem Review?
    13·1 answer
  • Only the one dose audio editors and video editors know this
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!