Copyright 1996 by Addison-Wesley Publishing Company 218 Chapter 19 Hash Tables Copyright 1996 by Addison-Wesley Publishing Company 219 Linear probing hash table after each insertion 0 1 2 3 4 5 6 7 8 9 Hash( 89, 10 ) = 8 Hash( 18, 10 ) = 8 Hash( 49, 10 ) = 9 Hash( 58, 10 ) = 8 Hash( 9, 10 ) = 9 After Insert 89 After Insert 18 After Insert 49 After Insert 58 A 89 89 89 89 18 18 18 49 49 58 Copyright 1996 by Addison-Wesley Publishing Company 220 Quadratic probing hash table after each insertion (note that the table size is poorly chosen because it is not a prime number) 0 1 2 3 4 5 6 7 8 9 Hash( 89, 10 ) = 8 Hash( 18, 10 ) = 8 Hash( 49, 10 ) = 9 Hash( 58, 10 ) = 8 Hash( 9, 10 ) = 9 After Insert 89 After Insert 18 After Insert 49 After Insert 58 89 89 89 89 18 18 18 49 49 58 Copyright 1996 by Addison-Wesley Publishing Company 221 Chapter 20 A Priority Queue: The Binary Heap Copyright 1996 by Addison-Wesley Publishing Company 222 A complete binary tree and its array representation A BC D E F G H I J 0 12345678910111213 A BCDEFGHI J 1 23 5 9108 467 Copyright 1996 by Addison-Wesley Publishing Company 223 Heap order property X P PX ≤ Copyright 1996 by Addison-Wesley Publishing Company 224 Two complete trees (only the left tree is a heap) 13 21 16 24 31 19 68 65 26 32 13 21 631 65 26 32 Copyright 1996 by Addison-Wesley Publishing Company 225 Attempt to insert 14, creating the hole and bubbling the hole up 13 21 16 24 31 19 68 65 26 32 1 3 21 24 65 26 32 31 14 Copyright 1996 by Addison-Wesley Publishing Company 226 The remaining two steps to insert 14 in previous heap 13 16 24 21 19 68 65 26 32 1 14 24 21 65 26 32 31 14 14 31 Copyright 1996 by Addison-Wesley Publishing Company 227 Creation of the hole at the root 13 14 16 19 21 19 68 65 26 32 14 19 21 65 26 32 31 Min=13 31 . 218 Chapter 19 Hash Tables Copyright 1996 by Addison-Wesley Publishing Company 219 Linear probing hash table after each insertion 0 1 2 3 4 5 6 7 8 9 Hash( 89, 10 ) = 8 Hash( 18, 10 ) = 8 Hash( 49,. probing hash table after each insertion (note that the table size is poorly chosen because it is not a prime number) 0 1 2 3 4 5 6 7 8 9 Hash( 89, 10 ) = 8 Hash( 18, 10 ) = 8 Hash( 49, 10 ) = 9 Hash( . insertion 0 1 2 3 4 5 6 7 8 9 Hash( 89, 10 ) = 8 Hash( 18, 10 ) = 8 Hash( 49, 10 ) = 9 Hash( 58, 10 ) = 8 Hash( 9, 10 ) = 9 After Insert 89 After Insert 18 After Insert 49 After Insert 58 A 89