CSE 326, Spring 1997: Homework 2

Due 4/16/97

For each problem below you will be asked to design an algorithm. In addition to giving the pseudocode for the algorithm, give an explanation of why the algorithm works.
  1. (20 points) A sparse matrix is one where a high percentage of the entries are zero. An nxn sparse matrix can be represented efficiently in an adjaceny list like structure, called the "sparse matrix representation". The sparse matrix representation consists of an array R[1..n] of pointers where R[i] points to an list of nodes corresponding to non-zero entries of in row i of the matrix. Each node of the data structure has three fields ["column", "value", "next"]. The node [j,v,p] is on R[i]'s list if the matrix has value v in position [i,j]. There is no entry of the form [j,v,p] on R[i]'s list if the matrix has value 0 in position [i,j]. The nodes in R[i]'s list are sorted by column number in increasing order.
  2. (10 points) Find the order of magnitude for each of the following recurrences: You can assume that n is a power of two in your derivations.
  3. (10 points) In this problem you should carefully design and analyze a list oriented recursive mergesort algorithm. Assume the input data is found in an unsorted linked list. Mergesort should return (destructively) a sorted list. Mergesort first splits the list into two approximately equal length lists, recursively mergesorts the two lists, then merges the two sorted lists into a final sorted list. You can assume you have already defined a split function that returns a duo with half the list in the field and the other half in the second field.
Try to make your pseudocode as simple and elegant as possible.