



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




COS 126 General Computer Science Spring 2007
(a) A data type is a set of values and a set of operations on those values. This definition was given repeatedly both in lecture and in the textbook.
(b) C A data type whose representation is hidden from the client.
D After constructing an object of this type, you cannot change its value.
B int
A When an object of this type is passed to a function, the function can, in general, change its value.
A. Reference type.
B. Primitive type.
C. Abstract (encapsulated) data type.
D. Immutable data type.
(c) Programmers use data types to:
A Implement recursion.
E Parse an NCBI genome data file.
A Evaluate an arithmetic expression.
A Implement the back button in a browser.
D Model pairwise relationships in facebook.
C Search for an IP address given a domain name.
B Model the buffer in the Karplus-Strong algorithm for simulating the pluck of a guitar string.
A. Stack
B. Queue
C. Symbol table
D. Graph
E. Regular expression
Catastrophic cancellation. This is the same example from lecture. The underlying reason is that only a finite number of real numbers can be exactly repre- sented in floating point number. So calculations involving floating point numbers are subject to roundoff error. This problem is magnified when subtracting two nearly equal numbers, resulting in a devastating loss of precision. For example, if x = 1.1e-8, then Math.cos(x) is about 0.999999999999999889, which is accurate to 16 decimal places. However, when we compute 1.0 - Math.cos(x), the result is about 1.1102e-16, which isn’t even accurate to one decimal place!
There are 4 errors.
E Universal
C Undecidable
G Duality
H Church-Turing thesis
I Turing machine
D P
A NP
F NP-complete
A. The set of all search problems (i.e., solution can be checked in polynomial time).
B. A set of search problems that are believed to have no polynomial time solution.
C. A problem that cannot be solved by a Turing machine.
D. The set of all search problems that can be solved in polynomial time.
E. One machine can do any computational task.
F. If you can solve a problem in this class in polynomial time, then P = NP.
G. Programs and data are each encoded as sequences of bits and can be used interchangeably.
H. Anything computable in this universe can be computed by a Turing machine.
I. A simple, universal, model of computation.