PracticeFinal - CSE 260 Sample Final Exam ANSWERS Name:...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 260 Sample Final Exam ANSWERS Name: This sample test gives a general idea about the type of questions that may appear in the final exam and does not necessarily include every possible type of questions that may be asked in the final exam. You should practice this sample test as well as go through all the materials that were covered in the class. 1. (a) The mod function is defined as: mod p : Z Z ( p ), mod(x,p)=x mod p, and Z ( p ) = { , 1 , 2 , ...p- 1 } We can define add and multiplication in modulo arithmetic based on the following: a + p b = ( a + b ) mod p and a * p b = ( a.b ) mod p, where a, bZ ( p ) The addition and the multiplication table for the + 2 , * 2 , re- spectively, are as follows: + 2 | 0 1 * 2 | 0 1----|-----------|------ | 0 1 | 0 1 | 1 1 | 0 1 i. (5 points) Give the tables for + 3 and * 3 + 3 | 0 1 2 * 3 | 0 1 2----|--------------|---------- | 0 1 2 | 0 1 | 1 2 1 | 0 1 2 2 | 2 1 2 | 0 2 1 ii. (10 points) Give the following sum and product in base 3: 121 3 211 3 +220 3 * 211 3 - 1111 3 122221 3 (b) (5 points) Which integers between 20 and 30 are relatively prime to 30. (23, 29) 2. (15 points) Consider the following grammar G = ( V, T, S, P ), where V = { S, A, a, b, c } , T = { a, b, c } and the set of produc- tion rules P = { S aSb, S A, A cA, A , } (a) Give a derivation for the word aacccbb S aSb aaSbb aaAbb aacAbb aaccAbb aacccAbb aacccbb (b) Give the parse tree for the word. S a S b a S b A c A c A c A lambda (c) Give the language generated by the above grammar. { a i c * b i | i } 3. (12 points) Answer the following true/false (a) 000110 * 1 * * true (b) * 1 * * true (c) Following is a set of valid production rules for a regular gram- mar: false S aS S Sb S c (d) (1(((1 0)1)1)) is a valid regular expression. true (e) 1001 (1(((0 * 1)0)1)) true (f) Regular expression (1(((1 0) * 1)1)) is equivalent to the regular expression...
View Full Document

Page1 / 9

PracticeFinal - CSE 260 Sample Final Exam ANSWERS Name:...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online