CPSC 121: Models of Computation Assignment #4, due Wednesday, July 22nd, 2009 at 14:00



Similar documents
Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

C H A P T E R Regular Expressions regular expression

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Number Representation

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Lecture 16 : Relations and Functions DRAFT

Zabin Visram Room CS115 CS126 Searching. Binary Search

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Lecture 2: Regular Languages [Fa 14]

Solutions to In-Class Problems Week 4, Mon.

Automata and Formal Languages

Chapter 4 Lecture Notes

Lecture 7: NP-Complete Problems

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Reading 13 : Finite State Automata and Regular Expressions

Finite Automata. Reading: Chapter 2

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Automata and Computability. Solutions to Exercises

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

Bounded Cost Algorithms for Multivalued Consensus Using Binary Consensus Instances

Finite Automata and Regular Languages

Practice with Proofs

Regular Languages and Finite Automata

Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80)

Chapter 6: Episode discovery process

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

03 - Lexical Analysis

1 Approximating Set Cover

6.2 Permutations continued

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Lecture 8: Synchronous Digital Systems

1 Definition of a Turing machine

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Introduction to Automata Theory. Reading: Chapter 1

The programming language C. sws1 1

Analysis of Binary Search algorithm and Selection Sort algorithm

Introduction to Theory of Computation

Cartesian Products and Relations

(1) /30 (2) /30 (3) /40 TOTAL /100

Searching Algorithms

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Proseminar on Semantic Theory Fall 2013 Ling 720. Problem Set on the Formal Preliminaries : Answers and Notes

Examination paper for MA0301 Elementær diskret matematikk

Computability Theory

NP-completeness and the real world. NP completeness. NP-completeness and the real world (2) NP-completeness and the real world

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

Solution for Homework 2

The Halting Problem is Undecidable

Constructing Digital Signatures from a One Way Function

Python Lists and Loops

Computational Models Lecture 8, Spring 2009

Hint 1. Answer (b) first. Make the set as simple as possible and try to generalize the phenomena it exhibits. [Caution: the next hint is an answer to

Notes on Complexity Theory Last updated: August, Lecture 1

Arithmetic Coding: Introduction

Informatica e Sistemi in Tempo Reale

Graph Theory Problems and Solutions

Computing exponents modulo a number: Repeated squaring

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

Ex. 2.1 (Davide Basilio Bartolini)

Lecture 10: CPA Encryption, MACs, Hash Functions. 2 Recap of last lecture - PRGs for one time pads

Testing LTL Formula Translation into Büchi Automata

(Refer Slide Time: 01.26)

Fast string matching

Chapter 3. Distribution Problems. 3.1 The idea of a distribution The twenty-fold way

Finite Automata. Reading: Chapter 2

Generating Elementary Combinatorial Objects

College of information technology Department of software

Dedekind s forgotten axiom and why we should teach it (and why we shouldn t teach mathematical induction in our calculus classes)

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014

Programming Assignment II Due Date: See online CISC 672 schedule Individual Assignment

Udacity cs101: Building a Search Engine. Extracting a Link

5. Factoring by the QF method

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Lecture 17 : Equivalence and Order Relations DRAFT

Moving from CS 61A Scheme to CS 61B Java

THE SEARCH FOR NATURAL DEFINABILITY IN THE TURING DEGREES

3.6. The factor theorem

ABET General Outcomes. Student Learning Outcomes for BS in Computing

Optimization Is Easy and Learning Is Hard In the Typical Function

Randomized Hashing for Digital Signatures

IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

Discuss the size of the instance for the minimum spanning tree problem.

Introduction to computer science

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

Introduction to Turing Machines

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

Lecture 4: Exact string searching algorithms. Exact string search algorithms. Definitions. Exact string searching or matching

The string of digits in the binary number system represents the quantity

3. Mathematical Induction

Lecture 4: Binary. CS442: Great Insights in Computer Science Michael L. Littman, Spring I-Before-E, Continued

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, To gain experience with Strings. Objective

CHAPTER 6. Shannon entropy

Pigeonhole Principle Solutions

Transcription:

CPSC 2: Models of Computation ssignment #4, due Wednesday, July 22nd, 29 at 4: Submission Instructions Type or write your assignment on clean sheets of paper with question numbers prominently labeled. nswers that are difficult to read or locate may lose marks. We recommend working problems on a draft copy then writing a separate final copy to submit. Your submission must be stapled below the CPSC 2 assignment cover page located at http://www. ugrad.cs.ubc.ca/ cs2/current/ssignments/assign-cover-page.pdf or a clearly legible reproduction of the same information. (If you are writing by hand, you may omit the text of the academic conduct policy, but you must include and sign the statement I understand the academic conduct policy and certify that my assignment follows it. and acknowledge assistance.) dditionally, include your name at the top of each page. We are not responsible for lost pages from unstapled submissions. Submit your assignment to the appropriately marked box outside of ICCS by the due date and time listed above. Late submissions are not accepted. Note: the number of marks allocated to a question appears in square brackets before the question number. Questions [6]. Consider each of the following equalities. If it is true for all sets, B and C, then prove it using the set identities. If it isn t, then give a couterexample that shows that it is not always true. (a) ( B) = B. (b) (B C) = ( B) ( C) [6] 2. Prove that for all subsets, B and C of the universal set U, if B C, then C B. [6] 3. Let and B be arbitrary sets contained in a universal set, U. Construct a formal proof to show that If B = ( B) (B ) then B = Hint: Try proving the contrapositive of the theorem using a proof by contradiction. [8] 4. There is a very important concept in Computer Science called hashing. hash function performs hashing by taking a potentially large and complex piece of data and representing it with a relatively short number. mong other things, we use hashing for security and robustness (i.e., sending a document and its hash to a recipient so that the recipient can check that the received document still matches the hash and is therefore probably not corrupted) and for highly efficient data structures called hash tables that store complex data in arrays, using the hashed value as the index in the array. Below is a link to the PI for the java.lang.object.hashcode() method. This java method is a hash function. While you re reading the PI, think about the definition of a function and think about which parts of the PI description of this method are directly based on the fact that the hashcode() method is a hash function. http://java.sun.com/javase/6/docs/api/java/lang/object.html#hashcode() (Note that it s not necessary to read the PI to answer the following questions) In this problem, you will explore hash functions.

[2] a. We ll consider a hash function that maps documents whose file size is exactly 8, bits to a 32-bit number. Of course, we can think of an 8, bit document as a 8,-bit binary number if we want. Write a formal description of our hash function h s domain and co-domain. Your answer should look like f : Z + Z but with the right function letter, domain, and codomain. (HINT: we can think of a 3-bit number as being drawn from the set {,, 2,..., 6, 7}. How can that help with your domain/co-domain?) [2] b. Is our hash function necessarily onto? Can it be onto? [2] c. Is our hash function one-to-one? Can it be one-to-one? [2] d. Hash tables must include a collision strategy: a way to deal with situations where more than one element has the same hash value (and would therefore be stored at the same place in the array the hash table uses). Either explain why this is necessary based on your answers to (b) and (c) or explain how hash tables could avoid such a strategy altogether (but still operate with the sample domain and co-domain we described in this question). [8] 5. For each of the following indicate whether it is -, whether it is onto, and whether it is a - correspondence. Your answers must be well justified (a simple yes or no is not sufficient), but you need not formally prove them. [2] a. Negation over the integers. [2] b. ddition over the positive integers. (Note: we consider a function that takes two arguments to take a two-tuple. In this case, then, the domain is Z + Z + and the codomain is Z +. Multiplication works similarly!) [2] c. Multiplication over the positive integers. [2] d. Negation over 32-bit signed ints (using a two s complement representation). [8] 6. The following finite-state machines, starting in the designated starting state, will end up in an accepting state after seeing some strings consisting of characters taken from the given input alphabet Σ. escribe in English, and as simply as possible, the strings for which the machine ends up in an accepting state, i.e., the language the F accepts. Briefly explain your answer (but you need not prove your answer correct). [2] a. The alphabet Σ = {, }. [3] b. The alphabet Σ = {, }.,

[3] c. The alphabet Σ = {, }. Hint: think of the input as an unsigned integer; try running the first 5 unsigned binary integers through the F.) [6] 7. Let Σ = {, C, G, T }. esign a F that accepts exactly the strings that start with either or T, and end with a character different from the one they started from. For instance, your F should accept the strings CCGGTC and TCGCCT but not the strings CGGTC or GGC- CCGC. (s always, write your answer neatly; this is especially important with Fs!) [6] 8. esign a F that will accept exactly the strings over the alphabet {, B,..., Z} that contain the substring B, but not the substring C. For instance, your F should accept the strings BB- BLING, BSOLUTE and BOBB, but not CCIENT, BRCBR or COMPUTER. (Note: you can label an arc Σ to indicate that every input letter received while at the arc s initial state follows the arc or label it else to indicate that every input letter not otherwise labelled from the arc s initial state follows the arc.) [3] 9. Theoretically, the transition function of a F may or may not be onto. In practical terms, what would it mean if the transition function for a F was not onto? Could such a F be useful? If so, under what circumstances? If not, why not?

[6]. raw the F represented by the following sequential circuit. Label states so that their correspondence with the circuit is clear. Use prediction = and last = as your start state. (ssume the FFs ( flip flops) start with prediction = and last = and not in an undefined state.) Label arcs with the value of taken, i.e., or. States in which prediction is true should be accepting states.

[]. For practice only: Consider the following definition for a sequence of sets based on a F: R is the set containing the start state of the F. R is the union of R with all the states in the F that are connected to by arcs from the states in R. R 2 is the union of R with all the states in the F that are connected to by arcs from the states in R. nd so forth. (So, R n is the union of R n with all the states in the F that are connected to by arcs from the states in R n, where n.) [] a. What is the value of R R R 2 R 3...? [] b. For the following F, what is R 3? [] c. If a F had states that were not in R n for any non-negative integer n, what could you say about those states? [] 2. For practice only: Write regular expressions describing the following sets of strings: [3] a. Strings of s, Bs and Cs that do not contain two consecutive letters that are both or C. [4] b. Java comments that start with the characters /* and end at the next occurrence of the characters */. Since the character * has special meaning inside a regular expression, you can write [*] to represent it. Be careful: /* This is not all */ a comment*/ is not a valid comment, because there is an extra */ inside.