Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 280 Data Structures Professor John Peterson. Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of.

Similar presentations


Presentation on theme: "CS 280 Data Structures Professor John Peterson. Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of."— Presentation transcript:

1 CS 280 Data Structures Professor John Peterson

2 Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of notes. Think about all of the homework / projects / quizzes we’ve had. I’ll be doing something similar. There will be a little programming.

3 Project #6 In this project, we’re going to add Quicksort and enhance the presentation. We’ll also show 3 sorts at one time. It’s going to be in the wiki tonight.

4 Enhancing the Presentation Comments that are placed a label underneath the sort Highlight subregions of the array Start / stop button Speed slider

5 Code for Partition int partition(Sortable s, int low, int high) { int lo = low; int hi = high – 1; while (lo <= hi) { while (lo < high && s.gtr(high, lo)) lo++; while (hi >= low && !s.gtr(high, hi)) hi--; if (lo <= hi) { // in case they crossed … s.swap(lo, hi); lo++;hi--;}} s.swap(lo, high); return lo; }

6 Call Trees A “call tree” shows the different calls to methods and their arguments. For example, in sorting {2,4,3,7,1,8}, if the pivot is 4, this will generate calls to qs {2,3,1} and qs {7, 8}. I’m not worried about the ordering of elements coming out of partition – I could have said {2,1,3} as well. Let’s draw a full tree on the board.


Download ppt "CS 280 Data Structures Professor John Peterson. Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of."

Similar presentations


Ads by Google