October 20th – Hashing Conclusion + memory Analysis

Slides:



Advertisements
Similar presentations
Comp 122, Spring 2004 Hash Tables – 1. hashtables - 2 Lin / Devi Comp 122, Fall 2003 Dictionary Dictionary: »Dynamic-set data structure for storing items.
Advertisements

Hashing.
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
1 CSE 326: Data Structures Hash Tables Autumn 2007 Lecture 14.
Hashing (Ch. 14) Goal: to implement a symbol table or dictionary (insert, delete, search)  What if you don’t need ordered keys--pred, succ, sort, select?
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Lecture 6 Hashing. Motivating Example Want to store a list whose elements are integers between 1 and 5 Will define an array of size 5, and if the list.
Hashtables David Kauchak cs302 Spring Administrative Talk today at lunch Midterm must take it by Friday at 6pm No assignment over the break.
Hashing Chapter 7 Section 3. What is hashing? Hashing is using a 1-D array to implement a dictionary o This implementation is called a "hash table" Items.
Tirgul 11 Notes Hash tables –reminder –examples –some new material.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Hashtables David Kauchak cs302 Spring Administrative Midterm must take it by Friday at 6pm No assignment over the break.
Chapter 11 Sets © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
1 Principles revisited.NET: Two libraries: System.Collections System.Collections.Generics Data Structures and Collections.
Chapter 27 Hashing Jung Soo (Sue) Lim Cal State LA.
Binary Search Trees Implementing Balancing Operations Hash Tables
Design & Analysis of Algorithm Map
May 3rd – Hashing & Graphs
October 2nd – Dictionary ADT
Data Structures Using C++ 2E
May 17th – Comparison Sorts
Hashing Jeff Chastine.
UNIT – I Linked Lists.
April 19th – Avl Operations
Hashing, Hash Function, Collision & Deletion
Hash table CSC317 We have elements with key and satellite data
CSCI 210 Data Structures and Algorithms
CS 332: Algorithms Hash Tables David Luebke /19/2018.
Table Amortized cost: $3 Insert 5 Actual cost: $1.
Recitation 7 Hashing.
Cse 373 April 24th – Hashing.
Cse 373 May 15th – Iterators.
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Data Structures Using C++ 2E
Hashing Exercises.
Cse 373 April 12th – TreEs.
Cse 373 April 26th – Exam Review.
November 1st – Exam Review
Quadratic probing Double hashing Removal and open addressing Chaining
CSE373: Data Structures & Algorithms Lecture 7: AVL Trees
Hash Tables Part II: Using Buckets
Design and Analysis of Algorithms
Hash Table.
CMSC 341 Hashing (Continued)
Chapter 28 Hashing.
CSE 326: Data Structures: Midterm Review
Introduction to Hash Tables
CSE 2331/5331 Topic 8: Hash Tables CSE 2331/5331.
Data Structures and Algorithms
Chapter 21 Hashing: Implementing Dictionaries and Sets
Resolving collisions: Open addressing
Double hashing Removal (open addressing) Chaining
Data Structures and Algorithms
Sets, Maps and Hash Tables
Implementing Hash and AVL
CSE 373, Copyright S. Tanimoto, 2002 Hashing -
CS202 - Fundamental Structures of Computer Science II
A Hash Table with Chaining
Advanced Implementation of Tables
Hashing Sections 10.2 – 10.3 Lecture 26 CS302 Data Structures
Hash Tables Computer Science and Engineering
CSE 373 Separate chaining; hash codes; hash maps
CSE 326: Data Structures Lecture #12 Hashing II
Lecture No.02 Data Structures Dr. Sohail Aslam
Ch Hash Tables Array or linked list Binary search trees
CMSC 341 Lecture 12.
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
CO4301 – Advanced Games Development Week 12 Using Trees
CSE 326: Data Structures Lecture #14
Lecture-Hashing.
Presentation transcript:

October 20th – Hashing Conclusion + memory Analysis Cse 373 October 20th – Hashing Conclusion + memory Analysis

Assorted minutiae Office hour change 9 am Friday office hours moved to Monday at 9 am in CSE 220

Project 2 clarifications ChainingHashTables The hashtable must be an array of dictionaries, what the dictionary is determines the chain Your code is an interface between the supported functions of ChainingHash and the dictionaries you’ve written

Project 2 clarifications ChainingHashTables The hashtable must be an array of dictionaries, what the dictionary is determines the chain Your code is an interface between the supported functions of ChainingHash and the dictionaries you’ve written Dictionary vs. Set

Project 2 clarifications ChainingHashTables The hashtable must be an array of dictionaries, what the dictionary is determines the chain Your code is an interface between the supported functions of ChainingHash and the dictionaries you’ve written Dictionary vs. Set A dictionary stores key, value pairs A set contains only keys—membership is the important thing to track.

examples

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes What is the worst-case?

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes What is the worst-case? Resizing

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes What is the worst-case? Resizing This resize can be amortized to O(1) the same way array resizing did

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes What is the worst-case? Resizing This resize can be amortized to O(1) the same way array resizing did On average, however, we expect O(1) find so long as the table is well-maintained

Hashtable analysis If our table is properly maintained, we expect O(1) runtimes What is the worst-case? Resizing This resize can be amortized to O(1) the same way array resizing did On average, however, we expect O(1) find so long as the table is well-maintained Performance and memory are direct tradeoffs here.

Hashtable implementation Hashtables implement dictionaries

Hashtable implementation Hashtables implement dictionaries <Key, Value> pairs

Hashtable implementation Hashtables implement dictionaries <Key, Value> pairs Don’t allow duplicate keys

Hashtable implementation Hashtables implement dictionaries <Key, Value> pairs Don’t allow duplicate keys Keys with the same “value” must have the same hash code

Hashtable implementation Hashtables implement dictionaries <Key, Value> pairs Don’t allow duplicate keys Keys with the same “value” must have the same hash code For open addressing, stored either as an array of <key,value> class objects, or as two parallel arrays, one of keys and the other of values

Hashtable implementation Resizing

Hashtable implementation Resizing Only get O(1) operations if the table is well-maintained

Hashtable implementation Resizing Only get O(1) operations if the table is well-maintained Easy to get good runtimes, if you don’t consider memory

Hashtable implementation Resizing Only get O(1) operations if the table is well-maintained Easy to get good runtimes, if you don’t consider memory bigO analysis can apply to memory consumption in the same way it applies to clock cycles

Hashtable implementation Resizing Only get O(1) operations if the table is well-maintained Easy to get good runtimes, if you don’t consider memory bigO analysis can apply to memory consumption in the same way it applies to clock cycles Resizing takes O(n) extra memory, because you need to maintain the original hash table while you build the second.

Hashtable implementation Resizing Iterate through the table (these are not in any meaningful order)

Hashtable implementation Resizing Iterate through the table (these are not in any meaningful order) Insert each of the <k,v> pairs into the new hashtable (which may be larger or smaller) Move pointers to new hash table

Hashtable implementation Assorted things

Hashtable implementation Assorted things Prime table sizes Usually keep an array of all the primes that roughly double in size precalculated

Hashtable implementation Assorted things Prime table sizes Usually keep an array of all the primes that roughly double in size precalculated Finding primes is actually very computationally difficult,

Hashtable implementation Assorted things Prime table sizes Usually keep an array of all the primes that roughly double in size precalculated Finding primes is actually very computationally difficult, If n is large enough, finding the new prime can be the most consuming portion of the resize

Hashtable implementation Assorted things Prime table sizes Usually keep an array of all the primes that roughly double in size precalculated Finding primes is actually very computationally difficult, If n is large enough, finding the new prime can be the most consuming portion of the resize If a.equals(b) then a.hashcode() == b.hashcode()

Hashtable implementation Assorted things Prime table sizes Usually keep an array of all the primes that roughly double in size precalculated Finding primes is actually very computationally difficult, If n is large enough, finding the new prime can be the most consuming portion of the resize If a.equals(b) then a.hashcode() == b.hashcode() Hardware constraints, even if you have lots of memory, over allocating fails to take advantage of spatial locality and can be problematic

Hash tables Hash tables are a good overall data structure

Hash tables Hash tables are a good overall data structure Can provide O(1) access times

Hash tables Hash tables are a good overall data structure Can provide O(1) access times Can be memory inefficient

Hash tables Hash tables are a good overall data structure Can provide O(1) access times Can be memory inefficient Probing can fail, and delete with probing mechanisms is difficult

Hash tables Hash tables are a good overall data structure Can provide O(1) access times Can be memory inefficient Probing can fail, and delete with probing mechanisms is difficult Chaining can be a good balance, but there is a lot of overhead maintaining all those data structures