CS225 September 23, 2008
Youssef
Homework 2
Due Date: October 14, 2008


Problem 1: (20 points)

Consider an array x[0..n-1] of ascii characters. The Burrows-Wheeler Transform (BWT) of x works as follows:

  1. it forms a matrix A of all the n rotations of x;
  2. it sorts the rows of A lexicographically where every row is treated as a word; The outcome is a matrix B;
  3. it returns (y,L) where y is the last column of B, and L is the location of the original x in B;

a)      Apply BWT on the string ``baccaccb'', and also on the string ``the style of the cable'', where the blank character ' ' is less than any alphabetic character. Note that you can use Matlab ``sortrows'' command to sort the rows of A.

b)     Give a general algorithm that constructs B from (y,L).

c)     Give an algorithm to reconstruct x from (y,L) using the algorithm in (b).

d)     illustrate how the reconstruction algorithm works on the (y,L) produced in part (a) for ``baccaccb''.


Problem 2: (20 points)

Let $x$ and $y$ be two vectors of 32 components each where $x$(k)=(k3+k)/2, and $y$(k) = cos (k pi/32), for k=0,1,...,31.


a)      Compute the Fourier transform $X$ of $x$ and $Y$ of $y$.

b)     Compute the absolute values |$X$| and |$Y$| (i.e., magnitudes) of $X$ and $Y$ (that is, |$X$(k)| and |$Y$(k)| for all k).

c)      Identify the 17 smallest values in |$X$| and the 17 smallest values in |$Y$|.

d)      Let $\hat X$ be derived from $X$ by replacing each of the 17 smallest elements of $X$ by 0, and leaving the other elements intact. Define $\hat Y$ similarly. Define by $\hat x$ the inverse Fourier transform of $\hat X$, and $\hat y$ the inverse Fourier transform of $\hat Y$. Compute $\hat x$ and $\hat y$.

e)    Plot $x$ and $\hat x$ in one figure, and $y$ and $\hat y$ in another figure.

Problem 3: (20 points)

Let $x$ and $y$ be as in Problem 2. Let $X$ be the DCT of $x$, and $Y$ the DCT of $y$. Let $\hat X$ be derived from $X$ by replacing the last 17 elements of $X$ by zeros while keeping the first 15 elements the same, and define $\hat Y$ similarly from $Y$. Finally, let $\hat x$ be the inverse DCT of $\hat X$, and $\hat y$ the inverse DCT of $\hat Y$.

a)     Compute $X$, $Y$, $\hat x$, and $\hat y$.

b)     Plot $x$ and $\hat x$ in one figure, and $y$ and $\hat y$ in another figure.


Problem 4: (20 points)

a)     Same as Problem 2 with 3 exceptions: (1) the transform is Haar, (2) $\hat X$ is derived from $X$ by zeroing out the 17 smallest-magnitude elements of $X$, and (3) $\hat Y$ is derived from $Y$ by zeroing out the 17 smallest-magnitude elements of $Y$.

b)     Same problem as (a) except that the Transform is the Walsh-Hadamard transform. Use the Matlab ``hadamard'' command to generate the Hadamard matrix.


Problem 5: (25 points)

a)     Put in one figure the plots of $x$ and the 4 $\hat x$'s of the last three problems.

b)     For each of the four $\hat x$'s, compute the mean square error relative to $x$.

c)     Which of the four $\hat x$'s is the best reconstruction of $x$?

d)     Repeat (a), (b) and (c) for $y$ and its four $\hat y$'s.