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" 1

PRACTICE MIDTERM

 

1.      Programming

 

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:

 <= /o:p>

j/i _______________________

 <= /o:p>

j/i*x _______________________

 <= /o:p>

x*j/i _______________________

 <= /o:p>

x/i _______________________

 <= /o:p>

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        =     i;

 <= /o:p>

int m =3D        =     x;

 <= /o:p>

x =3D        =         j;


 Finite Automata

 <= /o:p>

 <= /o:p>

Draw the FA that accepts e= xactly the sentences from this language:

 

        &= nbsp;   (AB)*(BA)*

 <= /o:p>

 <= /o:p>

 <= /o:p>

 <= /o:p>

 <= /o:p>

 

 

 

 <= /o:p>

 <= /o:p>

 <= /o:p>

 <= /o:p>

 <= /o:p>

 <= /o:p>

2.      Turing Machines

 <= /o:p>

Look at these rules (#=3Dblank).

 <= /o:p>

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

 <= /o:p>

Given that the machine starts in state 0 and the head = is on the left most x on this tape

 <= /o:p>

xxyyxx##

^=

0=

 <= /o:p>

What does the tape look like when the machine halts?

 <= /o:p>

 <= /o: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)<= /p>

 

 

 

 

 

 

 

 

 

 

 

 

        &= nbsp;           &nbs= p;

------=_NextPart_01C4B9AE.6A60BFB0 Content-Location: file:///C:/187BA2AD/practice-midterm_files/header.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii"





PAGE=  

 

PAGE=   1

 

------=_NextPart_01C4B9AE.6A60BFB0 Content-Location: file:///C:/187BA2AD/practice-midterm_files/filelist.xml Content-Transfer-Encoding: quoted-printable Content-Type: text/xml; charset="utf-8" ------=_NextPart_01C4B9AE.6A60BFB0--