Test Midterm

Spring 2020

The questions below are due on Tuesday April 07, 2020; 07:34:00 PM.
 
You are not logged in.

If you are a current student, please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.csail.mit.edu) to authenticate, and then you will be redirected back to this page.
A Python Error Occurred:

Error on line 19 of Python tag (line 20 of source):
    kerberos = cs_user_info['username']

KeyError: 'username'

You have 120 minutes to do this exam. This exam is open notes and open internet, though you are not to use a C/C++ compiler or Python evaluator. You are also not to communicate with anybody else during the exam except for staff members.

A Python Error Occurred:

Error on line 5 of question tag.
    csq_soln = kerberos

NameError: name 'kerberos' is not defined

The array x is declared and defined as shown:

char x[30] = "one, two, three.";

A Python Error Occurred:

Error on line 10 of question tag.
    csq_msg_function = what_was_submitted

NameError: name 'what_was_submitted' is not defined

If somebody did the following:

x[7]= NULL;

what would the be printed out when the following call is made:

Serial.println(x);

What would be returned from calling Serial.println(x);?
"one, two, t"
"one, two, three."
"one, tw"
"one, two"
"one"
None of the above

Assuming x has still been modified like above (x[7]=NULL;), what would happen if you printed out the following:

Serial.println(x+8);

What would be returned from calling Serial.println(x+8);?
"one, tw"
", three."
""
"o, three."
None of the above

Consider a C/C++ function with the following declaration:

void fsm(int input, char* output);

The function fsm is stateful and behaves with the following synchronous state diagram (one transition per function call regardless of input).

Placeholder for Diagram 81d66b962c1d98d2464341c1fae230ed
Count Down Machine.

In addition, the function assigns a value to char* output based on the following logic:

  • If State is 4, output is "blastoff!"
  • Otherwise, output is "" (empty).

Answer the following questions:

Assume you start in State 0. If the sequence of inputs provided to fsm is: 0,0,3,2,1,0,3, what is the result of printing output on each step?

["","","","blastoff!","","",""]
["","","","","blastoff!","",""]
["","","","","","",""]
["blastoff!","","","","","blastoff!",""]
["","","","","","blastoff!",""]

What will the state of the FSM be after the following sequence of inputs: 0,0,3,4,5,2,0

What is the state of the system?
0
1
2
3
4