UM Sorting Algorithms Discussion


2 attachmentsSlide 1 of 2attachment_1attachment_1attachment_2attachment_2

Unformatted Attachment Preview

Sorting algorithms are one kind of algorithm whose performance may
depend upon the data. Choose one of the sorting algorithms or any
other algorithm and explain whether the there are any differences in
the best, average and worst cases. If there are no differences, explain
why not. If there are differences, describe the data in the different
cases and explain how the performance differs in each case.
CMSC 451 Homework 3
1. Shown below is the code for the insertion sort consisting of two recursive methods that
replace the two nested loops that would be used in its iterative counterpart:
void insertionSort(int array[])
insert(array, 1);
void insert(int[] array, int i)
if (i < array.length) { int value = array[i]; int j = shift(array, value, i); array[j] = value; insert(array, i + 1); } } int shift(int[] array, int value, int i) { int insert = i; if (i > 0 && array[i – 1] > value)
array[i] = array[i – 1];
insert = shift(array, value, i – 1);
return insert;
Draw the recursion tree for insertionSort when it is called for an array of length 5 with
data that represents the worst case. Show the activations of insertionSort, insert and
shift in the tree. Explain how the recursion tree would be different in the best case.
2. Refer back to the recursion tree you provided in the previous problem. Determine a
formula that counts the numbers of nodes in that tree. What is Big- for execution time?
Determine a formula that expresses the height of the tree. What is the Big- for memory?
3. Provide a generic Java class named SortedPriorityQueue that implements a priority
queue using a sorted list implemented with the Java ArrayList class. Make the
implementation as efficient as possible.
4. Consider the following sorting algorithm that uses the class you wrote in the previous
void sort(int[] array)
SortedPriorityQueue queue = new SortedPriorityQueue();
for (int i = 0; i < array.length; i++) queue.add(array[i]); for (int i = 0; i < array.length; i++) array[i] = queue.remove(); } Analyze its execution time efficiency in the worst case. In your analysis you may ignore the possibility that the array list may overflow and need to be copied to a larger array. Indicate whether this implementation is more or less efficient than the one that uses the Java priority queue. Grading Rubric Problem Problem 1 Meets 10 points Does Not Meet 0 points Recursion tree is drawn correctly (8) Recursion tree is not drawn correctly (0) Best case tree is described correctly (2) Best case tree is not described correctly (0) 10 points 0 points Provided correct formula for number of Did not provide correct formula for nodes in tree (3) number of nodes in tree (0) Problem 2 Problem 3 Provided correct Big-Theta for execution time (2) Did not provide correct Big-Theta for execution time (0) Provided correct formula for tree height (3) Did not provide correct formula for tree height (0) Provided correct Big-Theta for memory (2) Did not provide correct Big-Theta for memory (0) 10 points 0 points Provided class correctly implements a priority queue (4) Provided class does not correctly implement a priority queue (0) Provided class is generic (1) Provided class uses an array list (1) Provided class is not generic (0) Provided class does not use an array list (0) List in class is maintained in sorted order (2) List in class is not maintained in sorted order (0) Implementation is most efficient (2) Implementation is not most efficient (0) 10 points Problem 4 0 points Provided correct worst case analysis (8) Did not provide correct worst case analysis (0) Provided correct efficiency comparison to Java priority queue (2) Did not provide correct efficiency comparison to Java priority queue (0) Purchase answer to see full attachment Tags: programming Average Sorting Algorithms data. User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Looking for this assignment?

do my essay homework

Reviews, comments, and love from our customers and community

Article Writing

Great service so far. Keep doing what you do, I am really impressed by the work done.



PowerPoint Presentation

I am speechless…WoW! Thank you so much! Definitely, the writer is talented person. She provided me with an essay a day early before the due date!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast. I was in pretty desperate need for help to finish this paper before the due date, which was in nine hours.

M.H.H. Tony


Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time. Kate did a WONDERFUL job. I would highly recommend her.

Francisca N.


Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more. Very good at communicating & fast at replying. And change & corrections she put in the effort to go back and change it!

Mary J.


Essay (Any Type)

On time, perfect paper. All concerns & matters I had Tom was able to answer them! I will definitely provide him with more orders!

Prof. Kate (Ph.D)


Case Study

Awesome! Great papers, and early! Thank you so much once again! Definitely recommend to trust James with your assignments! He won’t disappoint!

Kaylin Green


Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.


Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. It’s like having a tutoring service available (:

Arnold W.



Perfect!I only paid about $80, which i think was a good price considering what my paper entailed. My paper was done early and it was well written!

Joshua W.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>