Содержание
- 2. CONTENT Preface Stack Queue Heap Heap >
- 3. PREFACE Logical Data Structures Linear (Stack, Queue, etc.) Non-linear (Tree, Hash-Table, Graph, etc.) A Linear data
- 4. STACK It is a linear data structure that follows the LIFO (Last-In-First-Out) principle Last added item
- 5. STACK:API boolean empty() – Returns whether the stack is empty – Time Complexity : O(1) int
- 6. STACK:EXAMPLE Topmost item at position n-1 (Array) Topmost item at position 0 (Linked List)
- 7. QUEUE It is a linear data structure that follows the FIFO (First-In-First-Out) principle First added item
- 8. QUEUE:API boolean empty() – Returns whether the queue is empty int size() – Returns the size
- 9. QUEUE:EXAMPLE It is also possible to provide two methods for each of the followings: Peek peek()
- 10. HEAP
- 11. HEAP It allows you to find the *largest/smallest element in the heap in O(1) time Extracting
- 12. HEAP:INSERTION – O(LOG(N)) A new item is added as the last element Recursive actions (traverse up):
- 13. HEAP:HEAPIFY – O(LOG(N)) Max Heap example Heapify(i) – fixes the violation of heap property at any
- 14. HEAP:EXTRACT_MIN – O(LOG(N)) Min Heap example A root item is replaced with the last element Recursive
- 15. HEAP:METHODS Public: empty() – Returns whether the heap is empty size() – Returns the size of
- 16. HEAP > There are several comparisons in Heap It is not possible to use >, Comparable
- 17. HEAP >
- 18. LITERATURE Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne, Addison-Wesley Chapter 1.3, 2.4
- 20. Скачать презентацию