CS3240: A
SSIGNMENT
0
Due: Monday January 23, 11:59 p.m.
This assignment does not count towards your semester grade.
General directions:
*
This is a closedbook, closed notes, closed calculator assignment.
*
The assignment is to be pledged.
Part 1 Directions:
*
No computersfor this part of the assignment.
*
Prepare your solution as a PDF file and submit via Collab.
Part 2 Directions:
*
Computers can be used for preparing and running your solution only.
*
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCS 3240
Page
1
P
ART
1
1. What is the two’s complement representation of the following numbers. State your answer in
16bit hexadecimal:
(a) 255
(b) 255
(c) 3240
(d) 3240
(e) 65535
(f) 65535
2. The IEEE 741 floatingpoint standard includes the notion of a “hidden” bit. Briefly explain
the idea of the hidden bit and explain why its use is possible.
3. Write the algebraic definition (i.e., do not try to enumerate the elements) of the set that con
sists of the integers between 1 and 1000 which are squares of other integers.
4. Write a predicate that is true if an integer is between 1 and 1000 and is the square of another
integer.
5. Suppose a function is defined as {(1, f), (2, a),(3, f), (4, d)} where the source is the set {1, 2, 3,
4, 5} and the target is the set {a, b, c, d, e, f}
(a) Is this function an injection? Why or why not?
(b) Is the function a surjection? Why or why not?
(c) Is the function total? Why or why not?
6. Write a
recursive
method that calculates the following recursive mathematical
definition:
public static int f(int n) {
Hint: the notation
x
denotes the integer obtained by truncating the fractional part of
x
. In
Java, integer division will do this.
7. Briefly explain the concept of a
critical section
.
8. Here is a grammar to produce an English sentence. (the numbers to the left are not part of the
grammar, they are production numbers):
(1)
<start>:== Over break I will <verb> <object> .
(2)
<verb> :== <verb> and <verb>  find  buy  eat
(3)
<object> :== children  food  presents  <adjective> <object>
(4)
<adjective> :== holiday  Santa’s  small  festive
Generate a sentence that is a valid statement according to this grammar using
<start>
as the
initial symbol. Make use of at least one production for each nonterminal. Write out your sen
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 KNIGHT
 Type theory, Nearest neighbor search

Click to edit the document details