ECE-C 301 Assignment 4: Final Review


Due: Tuesday March 12, 2008

I. Sorting, revisited

Convert quicksort into code, like we discussed in review class. Make it sort the Song object by the title field.

void quicksort( ArrayList<Song> A )
void quicksort( ArrayList<Song> A, int left, int right )
int partition( ArrayList<Song> A, int left, int right )
void swap( ArrayList<Song> A, int i, int j )

II. Linked lists

Create an insert function that will insert a linked list into a preexisting linked list. An example would be if [1, 2, 3, 4] were to be inserted into [0, 2, 4, 5] at position 2, the resulting linked list would be [0, 2, 1, 2, 3, 4, 4, 5].

void insert(Node D)

III. Binary Search Trees

Write a function that converts a tree into a binary search tree... any tree into a binary search tree. Hint: recreate the tree using functions discussed in class (not on lecture slides but should be in your notebooks).

void ConvertToBST( )

IV. Heaps

Implement heapify in Java for an array of TreeNode objects.

void heapify( ArrayList<TreeNode> A )
void siftDown( ArrayList<TreeNode> A, int start, int end)

Refer to the Wikipedia link in the lecture slide for the pseudocode.