{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

225_10_maxSort_proofs

# 225_10_maxSort_proofs - OurmidtermisTues.Oct.18( #...

This preview shows pages 1–6. Sign up to view the full content.

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

View Full Document
Our midterm is Tues. Oct. 18 (the course outline has been  revised to have this new date). Start work on Assignment #2 early so you can ask for help  if you need it. Mon. Oct. 10: Thanksgiving, no lab this week. Assignment 2 Part A: Due Wed. Oct. 12 Assignment 2 Part B: Due Fri. Oct. 14
3 public void maxSort(int size) {      int i, t, maxPos;            if (size <= 1) return;          maxPos=0;        for (i=1; i < size; i++)              if ( A[i] >= A[maxPos]   ) maxPos=i;         t= A[maxPos];        A[maxPos]= A[size-1];        A[size-1] = t;        maxSort(size-1);    }

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

View Full Document
Prove by induction: maxSort does n(n-1)/2  key comparisons  on a problem of  size n.
Critique this proof that n(n-1)/2 is correct: Basis (n=0): 0*(0-1)/2=0 so the base case holds.  [Induction step] Assume 1+2+ … + (n-1)= n(n-1)/2.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern