This preview shows pages 1–2. Sign up to view the full content.
Engineering
xercises
2. For the directed tree below, list the vertices in the
Exercises
1. For each of the following problems, give a precise
atement of the problem in the style used on page 3
order they would be visited by a preorder
traversal, a postorder traversal and an inorder
traversal.
a
statement of the problem in the style used on page 3.
Testing if a given string is a palindrome (reads the
same way forwards and backwards).
PUT: Character string
=a
. .
g
b
h
c
d
f
e
INPUT: Character string
sa
1
a
2
. . .
a
n
.
OUTPUT: True if
a
i
=
a
n
+1–
i
for 1
≤
i
≤
n
, else False.
Find a Hamiltonian cycle (a simple cycle that
includes every vertex) in an undirected graph.
preorder
:
a g d c b h f e
postorder: d c g b f e h a
inorder: d g c a b f
e
INPUT: An undirected graph
G
=(
V
,
E
) with
n
vertices.
OUTPUT: A list of vertices
u
1
,
u
2
, . . . ,
u
n
where
u
i
∈
V
for all
i
,
u
i
≠
u
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '09
 BUHLER
 Algorithms

Click to edit the document details