Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| courses:cs211:winter2018:journals:thetfordt:chapter2 [2018/01/28 19:17] – thetfordt | courses:cs211:winter2018:journals:thetfordt:chapter2 [2018/01/29 20:32] (current) – thetfordt | ||
|---|---|---|---|
| Line 38: | Line 38: | ||
| The author then walks through the problem: that we want to be able to add, delete, and select elements quickly when an algorithm calls for it. The author then walks through exactly what a priority queue is and shows that, by using one, a linear sequence of priority queue operations can be used to sort n numbers. | The author then walks through the problem: that we want to be able to add, delete, and select elements quickly when an algorithm calls for it. The author then walks through exactly what a priority queue is and shows that, by using one, a linear sequence of priority queue operations can be used to sort n numbers. | ||
| - | We then dive into heaps, as a data structure used to implement | + | We then dive into heaps, as a data structure used to implement |
| The Heapify-Up algorithm runs in O(log n) time. This algorithm adds an element to the end of a heap, determines if the element needs to be switched with its parent and if so, executes this swap and uses a recursive call. | The Heapify-Up algorithm runs in O(log n) time. This algorithm adds an element to the end of a heap, determines if the element needs to be switched with its parent and if so, executes this swap and uses a recursive call. | ||
