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 compu
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
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
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 gi
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
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
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
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
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
Fa
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,