CSE 2320 - Assignments - Assignment 8

Submit to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.

IMPORTANT: By submitting your answers, you are certifying that these answers have been exclusively your own work. All students enrolled in this course are expected to adhere to the UT Arlington Honor Code:

I pledge, on my honor, to uphold UT Arlington's tradition of academic integrity, a tradition that values hard work and honest effort in the pursuit of academic excellence. I promise that I will submit only work that I personally create or contribute to group collaborations, and I will appropriately reference any work from other sources. I will follow the highest standards of integrity and uphold the spirit of the Honor Code.


(Programming) Task 1 (15 pts.)

Implement a variation of quicksort (i.e., a variation of the version of quicksort defined by textbook programs 7.1 and 7.2), that chooses as pivot a random position in the array, as opposed to the last position. Your function should have the following signature:
void quicksort_random(int * a, int left, int right)
Submit your function in a program called task1.c.


(Programming) Task 2 (15 pts.)

Compare the running time of your solution for task 1 with the performance of the version of quicksort defined by textbook programs 7.1 and 7.2, by running both versions on omega, on the following cases: For this task, you should submit two things:


Task 3 (5 pts.)

(This is Problem 7.1 from the textbook).

Show, how quicksort (textbook program 7.1) sorts an array containing these characters: E A S Y Q U E S T I O N.


Task 4 (10 pts.)

(This is a modified version of Problem 8.1 from the textbook).

Suppose that an ordered file of size N is to be combined with an unordered file of size M, with M much smaller than N. Assume that you have a sorting program that takes about c1N lg N seconds to sort a file of size N and a merging program that takes about c1(N + M) seconds to merge a file of size N with one of size M. How many times faster than resorting is the suggested merge-based method, as a function of M, for N = 103, 106, and 109?


Task 5 (10 pts.)

(This is a modified version of Problem 8.2 from the textbook).

How does the strategy of using insertion sort for the whole file compare with the two methods postulated in the previous task? Assume that the small file is random, so each insertion goes about halfway into the large file, and the running time is about c1MN/2.


Task 6 (10 pts.)

(This is Problem 9.3 from the textbook).

Explain how to use a priority queue ADT to implement a stack ADT.


Task 7 (10 pts.)

(This is Problem 9.4 from the textbook).

Explain how to use a priority queue ADT to implement a queue ADT.


Task 8 (10 pts.)

(This is Problem 9.5 from the textbook).

Criticize the following idea: To implement find the maximum in constant time, why not keep track of the maximum value inserted so far, then return that value for the find_the_maximum operation?


Task 9 (5 pts.)

(This is Problem 9.17 from the textbook).

Is an array that is sorted in descending order a heap?


Task 10 (10 pts.)

(This is Problem 9.18 from the textbook).

The largest element in a heap must appear in position 1, and the second largest element must be in position 2 or position 3. Give the list of positions in a heap of size 15 where the kth largest element (i) can appear, and (ii) cannot appear, for k = 2, 3, 4 (assuming the values to be distinct).


How to submit

The assignment should be submitted via Blackboard. Submit a ZIPPED directory called Firstname_Lastname.zip. No other forms of compression are accepted, contact the instructor or TA if you do not know how to produce .zip files. The zipped directory should contain the following documents:

As stated on the course syllabus, programs must be in C or Java, and must run on omega.uta.edu. If you want to do this in any language other than C, you have to re-implement in that language all the code that is currently provided and implemented in C. If you want to use another language or platform, you must obtain prior written approval via e-mail by the instructor.

IMPORTANT: Pay close attention to all specifications on this page, including file names and submission format. Even in cases where your answers are correct, points will be taken off liberally for non-compliance with the instructions given on this page (such as wrong file names, wrong compression format for the submitted code, and so on). The reason is that non-compliance with the instructions makes the grading process significantly (and unnecessarily) more time consuming. Contact the instructor or TA if you have any questions.


Back to the list of assignments.