CSE 2320 - Assignments - Assignment 1

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.


Task 1 (10 pts.)

(This is Problem 1.1 from the textbook).

Give the output that a connectivity algorithm should produce when given the input 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3.


Task 2 - Programming (10 pts.)

(This is a modification of Problem 1.3 from the textbook).

Write a program that implements the quick-find slow-union solution, and that also prints out, after processing each link, how many sets are remaining. You can write your program from scratch, or you can modify program find_union1b.c. Save your program as task2.c (or replace .c by the appropriate file extension for your programming language).


Task 3 (10 pts.)

(This is Problem 1.4 from the textbook).

Show the contents of the id array after each union operation when you use the quick-find algorithm (Program 1.1) to solve the connectivity problem for the sequence 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3. Also give the number of times the program accesses the id array for each input pair.


Task 4 (10 pts.)

(This is Problem 1.6 from the textbook).

Give the contents of the id array after each union operation for the weighted quick-union algorithm running on the examples corresponding to Figure 1.7 and Figure 1.8.


Task 5 (10 pts.)

(This is Problem 1.7 from the textbook).

Show the contents of the id array after each union operation when you use the weighted quick-union algorithm (Program 1.3) to solve the connectivity problem for the sequence 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3. Also give the number of times the program accesses the id array for each input pair.


Task 6 (10 pts.)

(This is a modification of Problem 1.10 from the textbook).

Estimate the minimum amount of time (in days) that would be required for quick find (Program 1.1) to solve a problem with 109 objects and 106 input pairs, on a computer capable of executing 109 instructions per second. Assume that each iteration of the for loop requires at least 10 instructions.


Task 7 (10 pts.)

(This is Problem 1.11 from the textbook).

Estimate the maximum amount of time (in seconds) that would be required for weighted quick union (Program 1.3) to solve a problem with 109 objects and 106 input pairs, on a computer capable of executing 109 instructions per second. Assume that each iteration of the while loop requires at most 100 instructions.


Task 8 (10 pts.)

(This is Problem 1.14 from the textbook).

Give a sequence of input pairs that causes the weighted quick-union algorithm (Program 1.3) to produce a path of length 4.


Task 9 - Programming (10 pts.)

(This is a modification of Problem 1.16 from the textbook).

Modify Program 1.3 to implement full path compression, where we complete each union operation by making every node that we touch link to the root of the new tree. You can write your program from scratch, or you can modify program find_union4b.c. Save your program as task9.c (or replace .c by the appropriate file extension for your programming language).


Task 10 (10 pts.)

(This is Problem 1.19 from the textbook).

Give an example showing that modifying quick union (Program 1.3) to implement full path compression (see Exercise 1.16) is not sufficient to ensure that the trees have no long paths.


How to submit

The assignment should be submitted via Blackboard. Submit a ZIPPED directory called assignment.zip. No other forms of compression 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 use another language or platform, you must obtain prior 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.