Still under construction. Any question, please send email to me (tunan@paul.rutgers.edu).

 

 

1. Since the {} is equivalent to *, this language is all the strings which begin

 with a digit except 0 and end with a digit except 0, and have exactly one '.' in the middle.

 

2.

NFSA

 

DFSA

 

 

3.

 

D = &&B will incur an error, since we can’t do referencing two times on any variable.

 

A = ***C will not incur an error, since do dereferencing three times on a variable with int *** is valid.

 

4.

int main()

{

int a = 7;

int *ra;

int **x;

int ***b;

int ****y, ****z;

ra = &a;

x = &ra;

b = &x;

y = z = &b;

return 0;

}

 

Scheme:

1. (define (size? L p) (if (eq? (length L) p) #t #f))

2. to see if there is a duplicate member in L.

3.

(define (rp? L)

 (if (null? L) #f

     (let (rest (cdr L))

                  (if (member? (car L) rest) #t

              (rp? rest)

          )

 ))) 

 

4.

(define (add1 x)

        (+ x 1))

 

(define (incr L)

    (cond (( null? L) '())

          (else (cons (add1 (car L))

                      (incr (cdr L))) )

)) 

 

5

(define (incr L)

        (map add1 L))

 

6.

g = 0 if argument is 0

  = 1 if argument is positive

  = -1 if argument is negative

 

(define (g x) (cond ((> x 0) 1)

                    ((= x 0) 0)

                    (else   -1)

               ))

 

(define (ff L) (map g L))

 

Grammar:

(1) 1000 is in the language.

(2) the small shortest string is 10.

 

               G

               |

               S

              /  \

             1    X

                  |

                  0

 

(3) one 1 follow by at least one 0.

 

(4) 10+

 

(5)

 

 

(6)

 

false

true

true

? ( I am not sure what sentential ..is)

false

true

 

(7)

(a) impossible, since the value of the y and z is address of other

    variable which is not changable.

(b)

 x = 5;

 printf("%d \n", x);

 x = 10;

 printf("%d \n", x);

 printf("%d \n", x); 

 

(c)(d) I couldn't see any output indicated.