

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!


cs3723 Homework # 1 , Due: 1 / 31 / 08 (corrected 1 / 25 ) I. Computability: 1 / 17 Lecture, Ch. 2 of text book
Why are programs best considered to represent partial rather than total functions?
For each of the following function definitions, give the graph of the function. Say whether this is a partial function or a total function. If the function is partial, say where the function is defined and undefined:
(a) f(x) = if x + 2 > 3 then x * 5 else 1 / x (b) f(x) = if x < - 2 then 3 else f(x-2) (c) f(x) = if x = 0 then 1 else f(x-1)
(c.f., Exercise 2. 1 , Mitchell, p. 16 .)
What are three formal definitions of the class of computable functions?
What does it mean to say that a language is Turing-complete?
List three computer languages (including one not mentioned in class) that are Turing-complete?
Name one language (not mentioned in class) that you think is not Turing- Complete? What is it about the language that makes you think it is not Turing- Complete? If you use any web sites or other references to figure this out, please cite them.
On a Solaris machine (e.g., pandora.cs.utsa.edu), look at the man page for csh, do you think csh is Turing-complete? Why or why not?
What does the Church-Turing thesis tell us about the relative power (in terms of the kinds of functions that are computable) of the various general purpose pro- gramming language?
Usually, most general purpose programming languages are considered to be Turing-Complete; this is a slight simplification. What limitation(s) does a real program in a real programming language running on a real computer have that would prevent it from successfully executing an algorithm that solves a problem that is, in principle, computable?
Assuming you are given a program Halt 0 that can be used to determine whether a program that requires no input halts (c.f., Exercise 2. 2 , Mitchell, p. 17 .), is it possible to solve the Halting Problem using Halt 0? If so, explain your answer by describing how a program solving the halting problem would work. If you do not think Halt 0 would allow one to solve the Halting Problem, explain briefly, why you think so?
II. Lisp/Scheme: 1 / 22 , 1 / 24 Lecture; Ch. 3 of text book
What was the original application domain of the Lisp language?
List 4 major innovations of Lisp?
What are the differences between the eq, eql, equal and = functions in Lisp. What are the names of the equivalent functions in Scheme? (If you use an external reference, please cite your source.)
What list does the scheme program:
( cons ā a ( cons ( c a r ( cons ā b ā ( ) ) ) ( cdr ( cons ā c ( cons ād ā ( ) ) ) ) ) )
evaluate to? Diagram the in-memory layout of the data structure representing this list.
Do Exercise 3. 1 in Mitchell (cons cells)
Write a Scheme function that, when called with (factorial n), calculates the nth factorial.
Write a Scheme function that, when called with (count lst sym), counts the num- ber of occurrences of symbols equal? to sym in the list lst, in any nested lists embedded in lst in any lists nested nested lists) inside lst, or.... For example, (count ā(a b (a b (((b)))) b) āb) should evaluate to 4.
Do Exercise 3. 4 , Mitchell, p. 42 about the compose2 function
Do Exercise 3. 5 , Mitchell, p. 42 about garbage collection and computability