PS9-Slides Comparison of Searching Methods Unsorted Sorted Hashed
PS9-Slides Modulo 43 Table
PS9-Slides A hash Function for Integers. 1. break the long integer up into 3 pieces of 3 digits each - add a leading 0, if necessary, to make the 9 digits. 2. Add the three pieces; 3. Find the remainder of the division of this sum by M (= 67, in this case). Ex > > 553 % 67 = 17
PS9-Slides Distribution of h(x): x
PS9-Slides Table ADT void Initialize Table(Table T); bool isNullEntry(TableEntry E); bool isEmpty(Table T, int probe); void InsertTable(Table T, TableEntry newitem); TableEntry RetrieveTable(Table T, KeyType *target)
PS9-Slides Hash Table Definition
PS9-Slides President Hash Table
PS9-Slides Appendix D: President Names File (PresName.dat) George Washington John Adams Thomas Jefferson James Madison James Monroe John Quincy Adams Andrew Jackson Martin Van_Buren William H. Harrison John Tyler James Knox Polk Zachary Taylor Millard Fillmore Franklin Pierce James Buchanan Abraham Lincoln Andrew Johnson Ulysses Simpson Grant Rutherford B. Hayes James Abram Garfield Chester Alan Arthur Grover Cleveland Benjamin Harrison William McKinley Theodore Roosevelt William Howard Taft Woodrow Wilson Warren G. Harding Calvin Coolidge Herbert Clark Hoover Franklin D. Roosevelt Harry S. Truman Dwight D. Eisenhower John F. Kennedy Lyndon Baines Johnson Richard Milhous Nixon Gerald R. Ford Jimmy Carter Ronald Reagan George Bush Bill Clinton
PS9-Slides
Experimental Values for Hash Function Distribution Problem 1. Distribution of h(x) for Integers in IntKeys.dat x Problem 2. Distribution of h(x) for String Keys Developed from PresName.dat x
PS9-Slides Experimental Values for Hash Function Distribution Problem 3. Distribution of of Table Entries for President Hash Tables. Table Entry Locations: Linear Probing. x x Table Entry Locations: Double Hashing. x x
PS9-Slides Using Defines to Control Program Output #define _STUDY : #ifdef _STUDY printf(" Insert %s:\n",E.key); #endif // _STUDY :
PS9-Slides Using Defines to Select Functions (Macros) #define EQ(a,b) (!strcmp((a),(b))) #define EQ(a,b) ((a) == (b)) : if( EQ(E.Key,EmptyKey)) return true; else return false; :