Docsity

ECE 537 Homework 8: Foundations of Computing - Algorithms and Complexity, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 537 - Foundations of Computing
Prof. Sen
Homework #8
Due: Thursday, November 1, 2007 in class
1. Problem 16.2-2 in the Cormen et. al text.
2. Problem 16.2-4 in the Cormen et. al text.
3. Generalize Strassen’s matrix multiplication algorithm as we discussed in class to square matrices
whose sizes are not a power of 2. Describe how the generalized algorithm works, and provide an
analysis of its running time.
4. In the traveling salesman problem (TSP) we are given a graph Gthat consists of a set of nvertices
V={v1,...vn}that correspond to cities, along with a set of nonnegative edge weights E, where
eij corresponds to the distance between city viand vj. The goal is to find a tour that visits all
cities, returning to the starting city, and has minimal total distance. Assume that eii = 0, and that
eij =∞if there is no edge connecting cites viand vj.
(a) Develop a brute-force algorithm that will always solve this problem optimally. What is the
time complexity of your algorithm?
(b) Show that this problem has optimal substructure, and then develop an algorithm that at-
tempts to solve this problem by constructing a tour using a greedy strategy that always adds
the next closest city to the tour. What is the time complexity of your algorithm? Give an
example in which your greedy algorithm does not produce an optimal solution.
(c) Show that this problem has overlapping subproblems, and then use dynamic programming
to develop an algorithm that will always solve this problem optimally. Demonstrate how
your solution operates on the problem:
E=
0 10 15 20
5 0 9 10
6 13 0 12
8 8 9 0
What are the time and space complexities of your algorithm?
1

Partial preview of the text

Download ECE 537 Homework 8: Foundations of Computing - Algorithms and Complexity and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE 537 - Foundations of Computing Prof. Sen Homework # Due: Thursday, November 1, 2007 in class

  1. Problem 16.2-2 in the Cormen et. al text.
  2. Problem 16.2-4 in the Cormen et. al text.
  3. Generalize Strassen’s matrix multiplication algorithm as we discussed in class to square matrices whose sizes are not a power of 2. Describe how the generalized algorithm works, and provide an analysis of its running time.
  4. In the traveling salesman problem (TSP) we are given a graph G that consists of a set of n vertices V = {v 1 ,... vn} that correspond to cities, along with a set of nonnegative edge weights E, where eij corresponds to the distance between city vi and vj. The goal is to find a tour that visits all cities, returning to the starting city, and has minimal total distance. Assume that eii = 0, and that eij = ∞ if there is no edge connecting cites vi and vj.

(a) Develop a brute-force algorithm that will always solve this problem optimally. What is the time complexity of your algorithm? (b) Show that this problem has optimal substructure, and then develop an algorithm that at- tempts to solve this problem by constructing a tour using a greedy strategy that always adds the next closest city to the tour. What is the time complexity of your algorithm? Give an example in which your greedy algorithm does not produce an optimal solution. (c) Show that this problem has overlapping subproblems, and then use dynamic programming to develop an algorithm that will always solve this problem optimally. Demonstrate how your solution operates on the problem:

E =

What are the time and space complexities of your algorithm?