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]
2 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]2 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
Explain the need for data structures when developing software.
Sergio [31]

Solution:

It is  important because, it has to do operation on so without, data structures and algorithms.

It performs these operation:  

 1)Take an input

2) Process it  

3) Give back the output.

The input can be in any form, for ex while searching for directions on google maps,  the starting point and the destination as input to google maps, while logging in to any social sites, We have to give our email and password as input and so on.

Similarly, in the third step, the computer application gives us output in some form or the other.

To make this process efficient, we need to optimize all the three steps.

4 0
3 years ago
Which windows command always navigates the command-line interface back to the root directory?
Pie
The answer is "cd \".
5 0
3 years ago
Andy wants to touch up his holiday photographs because they appear too bright and the color is washed out. Which software applic
Veronika [31]
The application andy wants to use is adobe photoshop 
5 0
3 years ago
Which of the following is NOT a rule you should follow when creating a presentation?
Nataly_w [17]
False, Write in full sentences and paragraphs on your slides - It is your presentation! Make it how you want to 
8 0
3 years ago
Advantages of monolithic operating system? ​
Lyrx [107]

Advntage:

provides CPU scheduling, memory management, file management, and other operating system functions through system calls. The other one is that it is a single large process running entirely in a single address space.

Disadvantage: if anyone service fails it leads to an entire system failure

8 0
2 years ago
Other questions:
  • Crop marks are used on an illustration to indicate to the printer the
    10·1 answer
  • In the written Hawaiian language, only 13 letters are used: the five vowels (a,e,i,o, and u), and 8 consonants (h,k,l,m,n,p,w, a
    10·1 answer
  • ) Which is true about the agile method?
    7·1 answer
  • What does f.i.r.s.t stand for in robotics
    15·1 answer
  • How is this fictional tex in the people could fly different from the nonfictional text​
    12·2 answers
  • A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa
    6·1 answer
  • What is drop shipping and how it works on amazon?
    12·1 answer
  • Which term describes a visual object such as a picture, a table, or a text box?
    14·2 answers
  • Need help please asap
    9·1 answer
  • Which of these are tools used to diagnose and test code? Check all of the boxes that apply.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!