EECS 233 Written Assignment 4

EECS 233 Written Assignment 4 - EECS 233 Written...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EECS 233 Written Assignment #4 Due April, 25 (23:59:59 EST) The following problems are from either textbook. 1. What is the running time of quicksort for: (a) Sorted input (2 points) Depends on pivot choice. Best case Pivot: O(n log n) (b) Reverse-ordered input (2 points) Depends on pivot again. Best case Pivot: O(nlogn) 2. Our implementation of merge-sort involved merging pairs of sub-arrays into a temporary array and then copying the merged array of double size back into the original place of the input array. Please write a method that avoids this back copying (as was suggested by one of the students in the class). (Hint: you need to implement the merge-sort without recursion) (3 points) All that must be done is to ensure a merge into the array itself, rather than into a temp, followed by a copy-over: Thus, I have only rewritten the merge method to show that copy-back can be eliminated by simply doing the merge into the parent array itself: public static int[] merge(int[] parent, int[] one, int[] two, int oneIndex) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

EECS 233 Written Assignment 4 - EECS 233 Written...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online