Question

Consider the following code, and write the sequence of statements (Si) that will be executed for...

Consider the following code, and write the sequence of statements (Si) that will be executed for the values of (x,y) = (0,0), (0,1), (1,0), (1,1), (-1,-1)

S1
if x==0 and y==0:
   S2
elif x>0 and y>0:
   S3
elif x>0 or y>0:

S4

else:

S5

S6

0 0
Add a comment Improve this question Transcribed image text
Answer #1
If (x,y) = (0,0):
-----------------
S1, S2, S6

If (x,y) = (0,1):
-----------------
S1, S4, S6

If (x,y) = (1,0):
-----------------
S1, S4, S6

If (x,y) = (1,1):
-----------------
S1, S3, S6

If (x,y) = (-1,-1):
-----------------
S1, S5, S6

Please up vote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
Consider the following code, and write the sequence of statements (Si) that will be executed for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A sequential circuit has one input (X), a clock input (CLK), and two outputs (S and...

    A sequential circuit has one input (X), a clock input (CLK), and two outputs (S and V). X, S and V are all one-bit signals. X represents a 4-bit binary number N, which is input least significant bit first. S represents a 4-bit binary number equal to N + 3, which is output least significant bit first. At the time the fourth input occurs, V = 1 if N + 3 is too large to be represented by 4 bits;...

  • For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of...

    For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0)          s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...

  • Draw a stack diagram to show how the following code is executed and write the generated output. def sequence(n, m):...

    Draw a stack diagram to show how the following code is executed and write the generated output. def sequence(n, m): if n < 0: return 1 elif n + m > 5: return sequence(n, m - 1) else: return n * sequence(m - 1, n + 1) print(sequence(5, 3))

  • Consider the following state diagram, which items on the state table is correct for the switch...

    Consider the following state diagram, which items on the state table is correct for the switch between states and output values. (Fig. 31) So S1 YO S Sz %0 Ss S2 S4 0 So Next state Z2Z1 Current state A. B. C. D. S4 S5 S6 S7 X=0 54 S5 S5 S5 X=1 X=0 S1 01 S6 00 S7 01 S4 10 Fig. 31 X=1 10 00 00 00 A. Line A on the table OB Line B on the...

  • Draw a stack diagram to show how the following code is executed and write the generated...

    Draw a stack diagram to show how the following code is executed and write the generated output. def sequence(n, m): if n < 0: return 1 elif n + m > 5: return sequence(n, m - 1) else: return n * sequence(m - 1, n + 1) print(sequence(5, 3))

  • Please solve step by step. Find the following: a. lambda for s3 b. lambda for s4 c. lambda for s5 d. lambda for s6 -1 A...

    Please solve step by step. Find the following: a. lambda for s3 b. lambda for s4 c. lambda for s5 d. lambda for s6 -1 A,-60 /hr S1 S4 C3 -3 0.7 μ,-70 /hr 70 /hr 4 S3 ,3 0.8 35 / hr S5 -30 /hr S2 Hs- 20 /hr 0.2 2-45/hr S6 10 / hr -1 A,-60 /hr S1 S4 C3 -3 0.7 μ,-70 /hr 70 /hr 4 S3 ,3 0.8 35 / hr S5 -30 /hr S2 Hs-...

  • Show how the following four instructions will be executed within the MIPS pipeline. Also, show the...

    Show how the following four instructions will be executed within the MIPS pipeline. Also, show the forwarding paths needed. Use the graphical notation showing all stages of MIPS pipeline. Indicate all data dependencies. Which dependencies are data hazards that will be resolved via forwarding? Which dependencies are data hazards that will cause a stall? add $s3, $s4, $s6 sub $s5, $s5, $s2 lw $s7, 100 ($s5) add $s8, $s7, $s2

  • Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...

    Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...

  • Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6,...

    Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6, $s2, $s2 sw Ss6, 48(Ss1) a. Include stalls/nops in the code so it executes correctly in the cases of (i) No forwarding (ii) ALU-ALU for warding, (iii) Full forwarding b. In each case calculate the number of clock cycles required to execute the code c. Assume further that the clock cycle time is 110 ps with no forwarding, 120 ps with ALU-ALU forwarding and...

  • java a. What is printed by the following code? Explain your answer by showing how you...

    java a. What is printed by the following code? Explain your answer by showing how you computed the values of pos, s1, s2 and 53. String str = "2900 Bedford Ave Brooklyn NY 12230-6843"; int pos = str.indexOf(" ", str.indexOf(" ", 'B') + 1); String si = str.substring(o, pos); System.out.println("pos: + post sl: + sl); pos - str.indexOf("B", pos+1); pos = str.indexOf("B", pos+1); String s2 = str.substring(pos, str. indexOf(" ", pos)): System.out.println("pos: + pos + + s2); String s3 =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT