Assignment 2 Coen 352
Assignment 2 Coen 352
Concordia University
Data Structure
COEN 352: Summer ‘24
Table 1
Algorithm Name Chosen gap (h) Run time for every N value
2.2.4 Does the abstract in-place merge produce proper output if and only if the two
input subarrays are in sorted order? Prove your answer, or provide a counterexample.
2.3.5 Give a code fragment that sorts an array that is known to consist of items having
just two distinct keys.
2.2.14 Merging sorted queues. Develop a static method that takes two queues of sorted
items as arguments and returns a queue that results from merging the queues into
sorted order.
2.3.2 Show, in the style of the quicksort trace given in this section, how quicksort sorts
the array E A S Y Q U E S T I O N (for the purposes of this exercise, ignore the
initial shuffle).
2.3.11 Suppose that we scan over items with keys equal to the partitioning item’s key
instead of stopping the scans when we encounter them. Show that the running time
of this version of quicksort is quadratic for all arrays with just a constant number of
distinct keys.
Submission
You must submit a ZIP file that includes all your programs and related files. Name you ZIP file
exactly “Assignment2”. ONLY SUBMIT ONE ZIP FILE PER TEAM.
The programs must be in Java (.java file), any other type of file will not be marked. The
programs need to be titled exactly as “Ass2_Q1” and “Ass2_Q2”. I will open your
Assignment2 folder as a project, so name your main class differently for two questions (avoid duplicate
main.java). I will test your code using a random list containing 10000 integers. Also, place
the names and IDs of all team members (maximum 2 people per team) on the first line of
each file (commented). A team only needs one submission and team members will share
the same grades. If you want to be marked separately, put only your name and ID in your
program and submit separately. Comment your code.
For the table 1, fill that out in Assignment2.pdf and include the pdf in your ZIP file.