

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Weng; Class: Algorithms and Data Structures; Subject: Computer Science & Engineering; University: Michigan State University; Term: Spring 2009;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Due by 11:59 PM Friday 6 Feb 2009
Submit your work via Handin. Name your file
Do the following problems from Chapter 7 of the text. As always, we do not want just the “answers”, we want the reasoning behind the answers.
(a) The root is the original call. (b) Use median3 with no randomness (i.e. left, right, center) in calculat- ing the result. (c) Show each list after the median3 step. (d) Show each list after the swap step. (e) Give the parameters of every call to quicksort. (f) The order of the numbers needs to be correct at every step. (g) After each median step and swapping step, the pivot should be de- noted in some way. (h) It is not necessary to show the quicksort step on a list of three num- bers or less. Similarly, it’s not necessary to show the median step on a list of a single number. (i) For this exercise implement the quicksort exactly as it is in the book although there are other, alternative, ways to do quicksort. (j) Do not use insertion sort at all, even though the algorithm in the book on page 286 does for smaller inputs.
Take a look at the document hw03p1example.doc for an example of the type of answer that is expected. The particular example here was made with Open Office Draw, but you can make your figure by hand or however you like.
struct Node { int data; Node *next; };
For the doubly linked list, you will use:
struct Node { int data; Node *next; Node *prev; };