Download Presentation
## CS 261 - Winter 2010

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**CS 261 - Winter 2010**Tree Sort**Useful Properties of Sorted Data Structures**• Skip Lists (as well as AVL Trees, and various other data structures we will eventually see) have two useful properties • They have O(log n) insertion • They keep their elements in order Together, these combine for a particularly simple sorting algorithm**YASA - Yet Another Sorting Algorithm**How to sort an Array (lets call it A) Step 1. Copy elements from A into a sorted data structure Step 2. Copy elements from the data structure back into A**Lets Analyze the Execution Time**Assume there are N elements Step 1. Copy elements from A into a sorted data structure O( ?? ) Step 2. Copy elements from the data structure back into A O( ?? )**We couldn’t we do this with arrays?**• Why couldn’t we do tree sort with a sorted dynamic array? • Why not an ordinary dynamic array?**That’s pretty good**• The execution time O(n log n) is the best we have seen so far - pretty good. And it is simple • Anybody see a downside?