Presentation is loading. Please wait.

Presentation is loading. Please wait.

Nov 2, 2001CSE 373, Autumn 20011 Hash Table example 0 1 2 3 4 5 6 7 8 9 + marking deleted items + choice of table size.

Similar presentations


Presentation on theme: "Nov 2, 2001CSE 373, Autumn 20011 Hash Table example 0 1 2 3 4 5 6 7 8 9 + marking deleted items + choice of table size."— Presentation transcript:

1 Nov 2, 2001CSE 373, Autumn 20011 Hash Table example 0 1 2 3 4 5 6 7 8 9 + marking deleted items + choice of table size

2 Nov 2, 2001CSE 373, Autumn 20012 Priority Queue ADT Checkout line at the supermarket Printer queues operations: insert, deleteMin insertdeleteMin 6 2 15 23 12 18 45 3 7

3 Nov 2, 2001CSE 373, Autumn 20013 Simple implementations of the Priority Queue ADT insertdeleteMin list sorted list BST AVL tree (overkill?)

4 Nov 2, 2001CSE 373, Autumn 20014 Binary heaps Structure property Perfect binary tree – all leaves are at the same depth. 25 92 215 11 3071013 16 131922 height h 2 h+1 – 1 nodes 2 h – 1 non-leaves 2 h leaves

5 Nov 2, 2001CSE 373, Autumn 20015 Complete binary tree of height h For h = 0, just a single node. For h = 1, left child or two children. For h  2, either –the left subtree of the root is perfect with height h-1 and the right is complete with height h-1, OR –the left is complete with height h- 1 and the right is perfect with height h-2.

6 Nov 2, 2001CSE 373, Autumn 20016 Structure, continued Informally: A perfect binary tree of height h-1 with leaves added at height h in the leftmost positions. N-node heap of height h: h =  log N  2 h  N  2 h+1 - 1

7 Nov 2, 2001CSE 373, Autumn 20017 Representing Complete Binary Trees G ED CB A JKHI F L From node i, left child: right child: parent: 1 23 45 67 98101112 ABCDEFGHIJKL 012345678910111213 implicit (array) implementation:

8 Nov 2, 2001CSE 373, Autumn 20018 Why is it better? no pointers (space). *2, /2, + are faster operations than dereferencing a pointer. can get to parent easily Can we use the implicit representation for binary search trees?


Download ppt "Nov 2, 2001CSE 373, Autumn 20011 Hash Table example 0 1 2 3 4 5 6 7 8 9 + marking deleted items + choice of table size."

Similar presentations


Ads by Google