CSE 3101Z Design and Analysis of Algorithms Professor: James Elder Winter 2009 Assignment 1 Due 11:59pm Monday March 30 1. Universal and Existential Qualifiers (8 marks) Recall that a problem is computable if and only if there is an algorithm that ha
Chapter 10
Section 10.1.4 (pp. 314 315)
1.
a. The Turing machine replaces a symbols with b symbols and vice versa.
b. The Turing machine calculates f(x) = 2x. If given two input parameters, the Turing machine
calculates f(x, y) = 2x + y.
c. The Turing mac
Chapter 9
Section 9.1.4 (pp. 273)
1. We can solve this problem with a divide and conquer methodology. On the first pass, we would have
processors calculate and store the sums s1 + s2, s3 + s4, s5 + s6, s7 + s8, and so on. On the second pass, the
processor
Active and Cooperative Learning
Introduction and Overview
In a traditional lecture format, the instructor prepares a lecture on the material and, at the
appointed day and time, enters the class and gives a speech. The professor expects students to
have re
Chapter 2
Section 2.1.1 (pp. 34 35)
1. The direct solution is the return of the value 1 and does no additions. The division of the input is the
two subtractions in the calculation of N 1 and N 2. The combination of the solutions is the addition
in the ret
Chapter 5
Section 5.1.3 (pp. 137)
1.
a. Horners method
cfw_[(cfw_[(x+2)*x+6]*x+3*x+7)*x+0]*x+5*x+4
b. Preprocessed coefficients
x 4 +6
x7
( x 7
+2 x 6
+ 2x6
+6 x 5
+6 x 5
x
+2
+3 x 4
+3 x 4
x3
+2 x 2
+6 x
+3
+7 x 3
+0 x 2
+5 x
+4
+ 6 x3
+ 12 x 2
x3
12 x 2
Chapter 3
Section 3.1.3 (pp. 64 65)
1.
for j = 1 to N do
select Compare( list[j], key) from
case 1: break
case 0: return j
case 1: return 0
end select
end for
return 0
In the worst case, we will need to look at each element of the list. This will require
Chapter 1
Section 1.1.3 (pp. 9)
1.
count = 0
while not at the end of file do
read a character into ch
if ('A' ch) and (ch 'Z') then
count = count + 1
end if
end while
This algorithm will do N+1 checks for end of file. There are 2N comparisons of character
Chapter 7
Section 7.1.4 (pp. 225 226)
1.
a.
Pattern
Fail links
A
0
B
1
A
1
B
2
B
3
C
1
b.
Pattern
Fail links
A
0
B
1
C
1
A
1
B
2
C
3
c.
Pattern
Fail links
C
0
B
1
C
1
B
2
B
3
A
1
C
1
A
2
d.
Pattern
Fail links
B
0
B
1
A
2
B
1
B
2
C
3
A
1
C
1
2.
Pattern
Fai
Chapter 6
Section 6.1.3 (pp. 155 156)
1.
The words with three or fewer symbols in * are , a, c, aa, ac, ca, cc, aaa, aac, aca, acc,
caa, cac, cca, ccc
The words with three or fewer symbols in + are a, c, aa, ac, ca, cc, aaa, aac, aca, acc, caa,
cac, cca,