1 / 6

# CS 261 - Winter 2010

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

## CS 261 - Winter 2010

E N D

### Presentation Transcript

1. CS 261 - Winter 2010 Tree Sort

2. 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

3. 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

4. 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( ?? )

5. 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?

6. 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?

More Related