Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MULTIPLE CHOICE: A compiler designer is trying to decide between three code sequ

ID: 3890285 • Letter: M

Question

MULTIPLE CHOICE:

A compiler designer is trying to decide between three code sequences for a particular machine. Based on the hardware implementation, there are three different classes of instructions: Class A, Class B, and Class C, and they require one, two, and three cycles (respectively).

            Code 1 uses 300 of A, 200 of B, and 200 of C

            Code 2 uses 400 of A, 200 of B, and 100 of C

            Code 3 uses 500 of A, 200 of B, and 100 of C

            Code 4 uses 100 of A, 100 of B, and 300 of C

Which code will be the fastest?

a) Code 1

b) Code 2

c) Code 3

d) Code 4

Explanation / Answer

We know that Class A, Class B, and Class C, and they require one, two, and three cycles (respectively).So we will find total number of cycles in each one of these cases .And code with the minimum number of cycles will be fastes -

(a) Code 1 uses 300 of A, 200 of B, and 200 of C

so (300*1)+(200*2)+(200*3)=300+400+600=1300 cycles for implementation

(b)
Code 2 uses 400 of A, 200 of B, and 100 of C

so (400*1)+(200*2)+(100*3)=400+400+300=1100 cycles for implementation
(c)
Code 3 uses 500 of A, 200 of B, and 100 of C
so (500*1)+(200*2)+(100*3)=500+400+300=1200 cycles required for implementation

(d)
Code 4 uses 100 of A, 100 of B, and 300 of C
so (100*1)+(100*2)+(300*3)=100+200+900=1200 cycles for implementation

As we can see in the above results we need minimum 1100 cycles for implementation in case B , so case B will be fastest.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote