MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_01C4B9AE.6A60BFB0" This document is a Single File Web Page, also known as a Web Archive file. If you are seeing this message, your browser or editor doesn't support Web Archive files. Please download a browser that supports Web Archive, such as Microsoft Internet Explorer. ------=_NextPart_01C4B9AE.6A60BFB0 Content-Location: file:///C:/187BA2AD/practice-midterm.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii"
PRACTICE MIDTERM
1.
Part a. P= lease change the following while-loop to a for- loop.
int
i =3D 1;
int
n =3D 1;
while(
i > 22 ){
n =3D n + i*i;
i++;
}
Part b. G= iven the following code:
int
i =3D 10;
int
j =3D 20;
double
x =3D 30.0;
provide the values for the following:
j/i
_______________________
j/i*x
_______________________
x*j/i
_______________________
x/i
_______________________
Decide which lines below need to be modified to compil= e. Then make the change(s) necessary. (Use the definitions of i,j and x given above.)
int k =3D
int m =3D
x =3D =
j;
Finite Automata
Draw the FA that accepts e= xactly the sentences from this language:
&=
nbsp; (AB)*(BA)*
2.
Look at these rules (#=3Dblank).
0 x $ r 1
0 y $ r 0
0 # # r 2
1 x # r 1
1 y $ r 0
1 # # r 2
2 # $ l h
Given that the machine starts in state 0 and the head = is on the left most x on this tape
xxyyxx##
^
0
What does the tape look like when the machine halts?= p>
<=
span
style=3D'mso-list:Ignore'>3.&n=
bsp; Binary numbers
Given the value 11101010 = in binary (base 2), show the equivalent in decimal (base 10)?
What is the value of 159 = (decimal) in binary?
<=
span
style=3D'mso-list:Ignore'>4.&n=
bsp; Booleans
Fill in the following tru= th table:
|
a |
b |
(NOT a) OR (NOT b) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&=
nbsp; &nbs=
p;