Docsity

Assignment 4 for Data Structure and Algorithms | EECS 281, Assignments of Algorithms and Programming

Toggle sidebar
bg1
EECS 281 Fall 2007
Homework Assignment 4
Due Tuesday 12/04/07 at 1:00 PM
Instructions: Complete all problems and turn in a hard copy to the EECS 281
lock box in 2420 EECS by the specified due date. Type or write legibly and
include both your name and uniqname on each page of the assignment. There are
6 questions worth a total of 35 points.
1) (5 points) Run the Graham scan algorithm to compute the convex hull of
points below, starting from A. Give the points that appear on the trial hull
(after each iteration) in the order that they appear.
2) (6 points) Consider the following graph. Your task is to color each node with a
blue (B), maize (M) or white (W) color. A coloring is valid only if nodes in
every pair of adjacent nodes are assigned a different color. Use
Backtracking to find all possible solutions to the problem. You must use a
tree representation to illustrate your use of backtracking (w/ partial
solutions). The vertices must be considered in a numeric order and the colors
have to be tried in B, M, W order. Show all steps.
pf3

Partial preview of the text

Download Assignment 4 for Data Structure and Algorithms | EECS 281 and more Assignments Algorithms and Programming in PDF only on Docsity!

EECS 281 Fall 2007

Homework Assignment 4

Due Tuesday 12/04/07 at 1:00 PM

Instructions : Complete all problems and turn in a hard copy to the EECS 281 lock box in 2420 EECS by the specified due date. Type or write legibly and include both your name and uniqname on each page of the assignment. There are 6 questions worth a total of 35 points.

  1. (5 points) Run the Graham scan algorithm to compute the convex hull of points below, starting from A. Give the points that appear on the trial hull (after each iteration) in the order that they appear.
  2. (6 points) Consider the following graph. Your task is to color each node with a blue (B), maize (M) or white (W) color. A coloring is valid only if nodes in every pair of adjacent nodes are assigned a different color. Use Backtracking to find all possible solutions to the problem. You must use a tree representation to illustrate your use of backtracking (w/ partial solutions). The vertices must be considered in a numeric order and the colors have to be tried in B, M, W order. Show all steps.
  1. (6 points) Consider the longest common subsequence (LCS) algorithm and answer the following questions: a.) (4 points) Complete the entries in the table below for the sequences supercalafrag and amanaplan s u p e r c a l a f r a g a m a n a p l a n b.) (2 points) If we have two sequences of lengths x and y , what would be the time complexity (Big-O) of the LCS algorithm?
  2. (6 points) Tom lives in a large family. He has 4 sisters and 1 brother. He also has two children. All of his sisters are married (to one man each), and his brother is unmarried. Tom is married, and his wife has no siblings. Tom is the youngest child in his family. Tom's second oldest sister's father's third youngest daughter's husband owes Tom's father 3 times the amount that Tom's third oldest sister owes Tom. Tom's third oldest sister owes Tom half as much as Tom's second oldest sister owes Tom's fourth youngest sister, which is in turn precisely pi/2 times one quarter of the amount that Tom's youngest sister will receive from Tom's wife, if Tom's wife were to pay Tom's youngest sister the amount that Tom's wife owes Tom's youngest sister. Note: This problem has several steps, but is graded as a single problem. The steps defined are only listed to assist you in solving the problem. Step 1.) Suppose that Tom's wife owes Tom's youngest sister 5 dollars. Draw a directed graph for Tom's family. Use the vertices to represent Tom, Tom's brother, Tom's wife, Tom's father, each of Tom's 4 sisters, and each of his sisters' husbands. Label these vertices using letters from the set V = {T, W, B, 1, 2, 3, 4, H1, H2, H3, H4}, where Tom is labeled with T, his wife is labeled with W, his brother is labeled with B, his oldest sister is labeled with 1, his second oldest sister is labeled with 2, his oldest sister's husband is labeled with H1, his second oldest sister's husband is labeled with H2, and so on. A directed edge should exist from vertex X to vertex Y if and only if X owes Y some amount. The value of any edge from X to Y should be equal to the value that X owes Y.