Lecture8

Lecture8 - Algorithms in Systems Engineering IE170 Lecture...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Algorithms in Systems Engineering IE170 Lecture 8 Dr. Ted Ralphs IE170 Lecture 8 1 References for Todays Lecture Required reading CLRS Chapter 7 References D.E. Knuth, The Art of Computer Programming, Volume 3: Sorting and Searching (Third Edition), 1998. R. Sedgewick, Algorithms in C++ (Third Edition), 1998. IE170 Lecture 8 2 Quicksort We now discuss a sorting algorithm called quicksort similar to one that we saw in Lab 2. The basic quicksort algorithm is as follows. Choose a partition element. Partition the input array around that element to obtain two subarrays. Recursively call quick sort on the two subarrrays. Here is code for the basic algorithm. void quicksort(Item* data, const int l, const int r) { if (r <= l) return; int i = partition(data, l, r); quicksort(data, l, i-1); quicksort(data, i+1, r); } IE170 Lecture 8 3 Partitioning One big advantage of quicksort is that the partitioning (and hence the entire algorithm) can be performed in place. Here is an in place implementation of the partitioning function. IE170 Lecture 8 4 Analyzing Quicksort Questions to be answered How do we prove the correctness of quick sort? Does quicksort always terminate? Can we do some simple optimization to improve performance? What are the best case, worst case, and average case running times?...
View Full Document

Page1 / 14

Lecture8 - Algorithms in Systems Engineering IE170 Lecture...

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

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