Tutorial 12

Tutorial 12 -...

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

View Full Document Right Arrow Icon
CS 134 Tutorial #12: Sorting Algorithms and Efficiency Winter 2008 CS 134 Tutors 1.  Mergesort Here is the code for the mergesort method: public static void mergesort(Comparable[] tA, int first, int last) { if (last > first) { mid = (first+last) / 2; mergesort(tA, first, mid); mergesort(tA, mid+1, last); merge(tA, first, mid, last); * } } Question 1:  Show the contents of the given array just before the final call to merge, followed by the  final sorted contents. 1 2 0 9 6 5 4 8 7 3 ... Question 2:  Describe in English how one would implement the  merge  method, which mergesort calls  on the line indicated with an asterisk (*). You should give enough detail such that a CS 134 student  could take your description and translate it into code.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2.  Quicksort Consider the following unsorted array: Sandy Nate Ted Jason Truc Cathy Leo Mary Question 1:  What does the array look like  just after  the  first 
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/25/2010 for the course CS CS134 taught by Professor Cl during the Fall '07 term at Waterloo.

Page1 / 4

Tutorial 12 -...

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

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