Worst-case running time for RANDOMIZED-SELECT

Size: px
Start display at page:

Download "Worst-case running time for RANDOMIZED-SELECT"

Transcription

1 Worst-case running time for RANDOMIZED-SELECT is ), even to nd the minimum The algorithm has a linear expected running time, though, and because it is randomized, no particular input elicits the worst-case behavior Let the running time of RANDOMIZED-SELECT on an input array.. ] of elements be a random variable ); we obtain an upper bound on E[ ]as follows The procedure RANDOMIZED-PARTITION is equally likely to return any element as the pivot MAT AA+DS, Fall Sep Therefore, for each such that 1, the subarray.. ] has elements (all less than or equal to the pivot) with probability 1/ For = 1,2,,, dene indicator random variables where =Ithesubarray.. hasexactlyelements Assuming that the elements are distinct, we have E = 1 When we choose ] as the pivot element, we do not know, a priori, 1) if we will terminate immediately with the correct answer, 2) recurse on the subarray.. 1], or 3) recurse on the subarray [ ] MAT AA+DS, Fall Sep

2 This decision depends on where the th smallest element falls relative to ] Assuming ) to be monotonically increasing, we can upper-bound the time needed for a recursive call by that on largest possible input I.e., to obtain an upper bound, we assume that the th element is always on the side of the partition with the greater number of elements For a given call of RANDOMIZED-SELECT, the indicator random variable has value 1 for exactly one value of, and it is 0 for all other When =1, the two subarrays on which we might recurse have sizes 1and MAT AA+DS, Fall Sep We have the recurrence (max( 1, )) + )) = (max(1,))+) Taking expected values, we have E E (max(1,))+) = E[ (max( 1, ))] + ) MAT AA+DS, Fall Sep

3 = E E[(max(1,))]+) = 1 E[(max( 1, ))] + ) The first Eq. on this slide follows by independence of random variables and max(1,) Consider the expression max(1,)= > /2 /2 MAT AA+DS, Fall Sep If is even, each term from /2 up to 1) appears exactly twice in the summation, and if is odd, all these terms appear twice and /2 appears once Thus, we have E[ 2 E ) We can show that E ) by substitution In summary, we can nd any order statistic, and in particular the median, in expected linear time, assuming that the elements are distinct MAT AA+DS, Fall Sep

4 III Data Structures Elementary Data Structures Hash Tables Binary Search Trees Red-Black Trees Augmenting Data Structures Dynamic sets Sets are fundamental to computer science Algorithms may require several different types of operations to be performed on sets For example, many algorithms need only the ability to insert elements into, delete elements from, and test membership in a set We call a dynamic set that supports these operations a dictionary MAT AA+DS, Fall Sep

5 Operations on dynamic sets Operations on a dynamic set can be grouped into queries and modifying operations SEARCH ) Given a set and a key value, return a pointer to an element in such that, or NIL if no such element belongs to INSERT ) Augment the set with the element pointed to by. We assume that any attributes in element have already been initialized DELETE ) Given a pointer to an element in the set, remove from. Note that this operation takes a pointer to an element, not a key value MINIMUM) A query on a totally ordered set that returns a pointer to the element of with the smallest key MAT AA+DS, Fall Sep MAXIMUM) Return a pointer to the element of with the largest key SUCCESSOR ) Given an element whose key is from a totally ordered set, return a pointer to the next larger element in, or NIL if is the maximum element PREDECESSOR ) Given an element whose key is from a totally ordered set, return a pointer to the next smaller element in, or NIL if is the minimum element We usually measure the time taken to execute a set operation in terms of the size of the set E.g., we later describe a data structure that can support any of the operations on a set of size in time (lg ) MAT AA+DS, Fall Sep

6 11 Hash Tables Often one only needs the dictionary operations INSERT, SEARCH, and DELETE Hash table effectively implements dictionaries In the worst case, searching for an element in a hash table takes ) time In practice, hashing performs extremely well Under reasonable assumptions, the average time to search for an element is (1) MAT AA+DS, Fall Sep Hash tables A set of keys is stored in a dictionary, it is usually much smaller than the universe of all possible keys A hash table requires storage ( ) while search for an element in it only takes (1) time The catch is that this bound is for the average-case time MAT AA+DS, Fall Sep

7 An element with key is stored in slot (); that is, we use a hash function to compute the slot from the key 0,1,, 1 maps the universe of keys into the slots of hash table [0.. 1] The size of the hash table is typically We say that an element with key hashes to slot or that ) is the hash value of If hash to same slot we have a collision Effective techniques resolve the conict MAT AA+DS, Fall Sep MAT AA+DS, Fall Sep

8 The ideal solution avoids collisions altogether We might try to achieve this goal by choosing a suitable hash function One idea is to make appear to be random, thus minimizing the number of collisions Of course, must be deterministic so that a key always produces the same output ) Because, there must be at least two keys that have the same hash value; avoiding collisions altogether is therefore impossible MAT AA+DS, Fall Sep Collision resolution by chaining In chaining, we place all the elements that hash to the same slot into the same linked list Slot contains a pointer to the head of the list of all stored elements that hash to If no such elements exist, slot contains NIL The dictionary operations on a hash table are easy to implement when collisions are resolved by chaining MAT AA+DS, Fall Sep

9 CHAINED-HASH-INSERT ) 1. insert at the head of list ] CHAINED-HASH-SEARCH ) 1. search for element with key in list ] CHAINED-HASH-DELETE ) 1. delete from the list [. ] MAT AA+DS, Fall Sep Worst-case running time of insertion is (1) It is fast in part because it assumes that the element being inserted is not already present in the table For searching, the worst-case running time is proportional to the length of the list; we analyze this operation more closely soon We can delete an element (given a pointer) in (1) time if the lists are doubly linked In singly linked lists, to delete, we would rst have to nd in the list [. ] MAT AA+DS, Fall Sep

10 Analysis of hashing with chaining A hash table of slots stores elements, dene the load factor, i.e., the average number of elements in a chain Our analysis will be in terms of, which can be <1,=1, or >1 In the worst-case all keys hash to one slot The worst-case time for searching is thus ) plus the time to compute the hash function MAT AA+DS, Fall Sep Average-case performance of hashing depends on how well distributes the set of keys to be stored among the slots, on the average Simple uniform hashing (SUH): Assume that an element is equally likely to hash into any of the slots, independently of where any other element has hashed to For = 0,1,, 1, let us denote the length of the list ] by, so and the expected value of is E[ ] = = / MAT AA+DS, Fall Sep

11 Theorem 11.1 In a hash table which resolves collisions by chaining, an unsuccessful search takes average-case time (1 + ), under SUH assumption. Proof Under SUH, not already in the table is equally likely to hash to any of the slots. The time to search unsuccessfully for is the expected time to go through list )], which has expected length E[ ) ]=. Thus, the expected number of elements examined is, and the total time required (including computing ()) is (1 + ). MAT AA+DS, Fall Sep Theorem 11.2 In a hash table which resolves collisions by chaining, a successful search takes average-case time (1 + ), under SUH. Proof We assume that the element being searched for is equally likely to be any of the elements stored in the table. The number of elements examined during the search for is one more than the number of elements that appear before in s list. Elements before in the list were all inserted after was inserted. MAT AA+DS, Fall Sep

12 Let us take the average (over the table elements ) of the expected number of elements added to s list after was added to the list + 1 Let, = 1,2,,, denote the th element inserted into the table and let For keys and, dene the indicator random variable = I{ } Under SUH, Pr = 1, and by Lemma 5.1, E[ ] = 1 MAT AA+DS, Fall Sep Thus, the expected number of elements examined in successful search is E 1 1+ = 1 1+ E = MAT AA+DS, Fall Sep

13 =1+ 1 =1+ 1 ) = ) 2 =1+ 1 = Thus, the total time required for a successful search is = 1 + MAT AA+DS, Fall Sep If the number of hash-table slots is at least proportional to the number of elements in the table, we have ) and, consequently, (1) Thus, searching takes constant time on average Insertion takes (1)worst-case time Deletion takes 1 worst-case time when the lists are doubly linked Hence, we can support all dictionary operations in (1) time on average MAT AA+DS, Fall Sep

14 11.3 Hash functions A good hash function satises (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way to check this condition, since we rarely know the probability distribution from which the keys are drawn The keys might not be drawn independently MAT AA+DS, Fall Sep If we, e.g., know that the keys are random real numbers independently and uniformly distributed in the range <1 Then the hash function = satises the condition of SUH In practice, we can often employ heuristic techniques to create a hash function that performs well Qualitative information about the distribution of keys may be useful in this design process MAT AA+DS, Fall Sep

15 In a compiler s symbol table the keys are strings representing identiers in a program Closely related symbols, such as pt and pts, often occur in the same program A good hash function minimizes the chance that such variants hash to the same slot A good approach derives the hash value in a way that we expect to be independent of any patterns that might exist in the data For example, the division method computes the hash value as the remainder when the key is divided by a specied prime number MAT AA+DS, Fall Sep Interpreting keys as natural numbers Hash functions assume that the universe of keys is natural numbers = {0,1,2, } We can interpret a character string as an integer expressed in suitable radix notation We interpret the identier pt as the pair of decimal integers (112,116), since = 112 and = 116 in ASCII Expressed as a radix-128 integer, pt becomes = 14,452 MAT AA+DS, Fall Sep

16 The division method In the division method, we map a key into one of slots by taking the remainder of divided by That is, the hash function is mod E.g., if the hash table has size = 12 and the key is = 100, then =4 Since it requires only a single division operation, hashing by division is quite fast MAT AA+DS, Fall Sep When using the division method, we usually avoid certain values of E.g., should not be a power of 2, since if =2, then ) is just the lowest-order bits of We are better off designing the hash function to depend on all the bits of the key A prime not too close to an exact power of 2 is often a good choice for MAT AA+DS, Fall Sep

17 Suppose we wish to allocate a hash table, with collisions resolved by chaining, to hold roughly = 2,000character strings, where a character has 8 bits We don t mind examining an average of 3 elements in an unsuccessful search, and so we allocate a hash table of size = 701 We choose = 701because it is a prime near 2000/3 but not near any power of 2 (2 = 512 and 2 = 1024) Treating each key as an integer, our hash function would be = mod701 MAT AA+DS, Fall Sep The multiplication method The method operates in two steps First, multiply by a constant, 0<<1, and extract the fractional part of Then, multiply this value by and take the oor of the result The hash function is = mod1) where modmeans the fractional part of, that is, MAT AA+DS, Fall Sep

18 Value of is not critical, we choose = 2 The function is implemented on computers Suppose that the word size of the machine is bits and that ts into a single word Restrict to be a fraction of the form 2, where is an integer in the range 0<<2 Multiply by the -bit integer 2 The result is a -bit value 2, where is the high-order word of the product and is the low-order word of the product The desired -bit hash value consists of the most signicant bits of MAT AA+DS, Fall Sep MAT AA+DS, Fall Sep

19 Knuth (1973) suggests that ( 1) is likely to work reasonably well Suppose that = 123,456, = 14, =2 = 16,384, and = 32 Let to be the fraction of the form 2 closest to ( 1), 2so that = 2,654,435,769/2 Then = 327,706,022,297,664 = 76, ,612,864, and = 76,300 and = 17,612,864 The 14 most signicant bits of yield the value = 67 MAT AA+DS, Fall Sep Open addressing In open addressing, all elements occupy the hash table itself That is, each table entry contains either an element of the dynamic set or NIL Search for element systematically examines table slots until we nd the element or have ascertained that it is not in the table No lists and no elements are stored outside the table, unlike in chaining MAT AA+DS, Fall Sep

20 Thus, the hash table can ll up so that no further insertions can be made the load factor can never exceed 1 We could store the linked lists for chaining inside the hash table, in the otherwise unused hashtable slots Instead of following pointers, we compute the sequence of slots to be examined The extra memory freed provides the hash table with a larger number of slots for the same amount of memory, potentially yielding fewer collisions and faster retrieval MAT AA+DS, Fall Sep To perform insertion, we successively examine, or probe, the hash table until we nd an empty slot in which to put the key Instead of being xed in order 0,1,, 1 (which requires ) search time), the sequence of positions probed depends upon the key being inserted To determine which slots to probe, we extend the hash function to include the probe number (starting from 0) as a second input MAT AA+DS, Fall Sep

21 Thus, the hash function becomes 0,1,, {0,1,, 1} With open addressing, we require that for every key, the probe sequence,0,,1,,1) be a permutation of 0,1,,1, so that every position is eventually considered as a slot for a new key as the table lls up Let us assume that the elements in the hash table are keys with no satellite information; the key is identical to the element containing key MAT AA+DS, Fall Sep HASH-INSERT either returns the slot number of key or ags an error because the table is full HASH-INSERT ) repeat 3. ) 4. if ]=NIL return 7. else until 9. error hash table overow MAT AA+DS, Fall Sep

22 Search for key probes the same sequence of slots that the insertion algorithm examined HASH-SEARCH ) repeat 3. ) 4. if ]= 5. return until = NIL 8. return NIL MAT AA+DS, Fall Sep When we delete a key from slot, we cannot simply mark it as empty by storing NIL in it We might be unable to retrieve any key during whose insertion we had probed slot Instead we mark the slot with value DELETED Modify HASH-INSERT to treat such a slot as empty so that we can insert a new key there HASH-SEARCH passes over DELETED values When we use DELETED value, search times no longer depend on the load factor Therefore chaining is more commonly selected as a collision resolution technique MAT AA+DS, Fall Sep

23 We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a whole probe sequence True uniform hashing is difcult to implement, however, and in practice suitable approximations (such as double hashing, dened below) are used MAT AA+DS, Fall Sep We examine three common techniques to compute the probe sequences required for open addressing: 1) linear probing, 2) quadratic probing, and 3) double hashing These techniques all guarantee that, 0),, 1),, 1) is a permutation of 0,1,, for each key No technique fullls the assumption of UH; none of them is capable of generating more than different probe sequences Double hashing has the greatest number of probe sequences and gives the best results MAT AA+DS, Fall Sep

24 Linear probing Given a hash function 0,1,,1, an auxiliary hash function, use the function = mod Given key, we rst probe the slot given by the auxiliary hash function ] We next probe slots +1,,1] Wrap around to 0, 1,, 1] Initial probe determines the entire probe sequence, there are only distinct seq s MAT AA+DS, Fall Sep Linear probing is easy to implement, but it suffers from a problem known as primary clustering Long runs of occupied slots build up, increasing the average search time Clusters arise because an empty slot preceded by full slots gets lled next with probability +1) Long runs of occupied slots tend to get longer, and the average search time increases MAT AA+DS, Fall Sep

25 Quadratic probing Use a hash function of the form = ( mod where are positive auxiliary constants Initial position probed is ]; later positions are offset by amounts that depend in a quadratic manner on the probe number This works much better than linear probing, but to make full use of the hash table, the values of, and are constrained MAT AA+DS, Fall Sep Also, if two keys have the same initial probe position, then their probe sequences are the same, since,0 =,0 implies This property leads to a milder form of clustering, called secondary clustering As in linear probing, the initial probe determines the entire sequence, and so only distinct probe sequences are used MAT AA+DS, Fall Sep

26 Double hashing One of the best methods available for open addressing, the permutations produced have many characteristics of random ones Uses a hash function of the form = ( ))mod where and are auxiliary hash functions The initial probe goes to position ; successive probes are offset from previous positions by the amount (), modulo MAT AA+DS, Fall Sep Here we have a hash table of size 13 with mod13and = 1 + (mod11) Since 14 mod13 and 14 mod11, we insert the key 14 into empty slot + 2 = 9, after examining slots =1and =5and nding them to be occupied MAT AA+DS, Fall Sep

27 The value ) must be relatively prime to for the entire hash table to be searched A convenient way to ensure this condition is to let be a power of 2 and to design so that it always produces an odd number Another way is to let be prime and to design so that it always returns a positive integer less than For example, we could choose prime and let mod, = 1 + (mod), where is slightly less than (say, 1) MAT AA+DS, Fall Sep E.g., if = 123,456, = 701, and = 700, we have = 80 and = 257 We rst probe position 80, and then we examine every 257 th slot (modulo ) until we nd the key or have examined every slot When is prime or a power of 2, double hashing improves over linear or quadratic probing in that ) probe sequences are used, rather than ) Each possible )pair yields a distinct probe sequence MAT AA+DS, Fall Sep

III Data Structures. Dynamic sets

III Data Structures. Dynamic sets III Data Structures Elementary Data Structures Hash Tables Binary Search Trees Red-Black Trees Dynamic sets Sets are fundamental to computer science Algorithms may require several different types of operations

More information

9/24/ Hash functions

9/24/ Hash functions 11.3 Hash functions A good hash function satis es (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way

More information

We assume uniform hashing (UH):

We assume uniform hashing (UH): We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a

More information

II (Sorting and) Order Statistics

II (Sorting and) Order Statistics II (Sorting and) Order Statistics Heapsort Quicksort Sorting in Linear Time Medians and Order Statistics 8 Sorting in Linear Time The sorting algorithms introduced thus far are comparison sorts Any comparison

More information

COMP171. Hashing.

COMP171. Hashing. COMP171 Hashing Hashing 2 Hashing Again, a (dynamic) set of elements in which we do search, insert, and delete Linear ones: lists, stacks, queues, Nonlinear ones: trees, graphs (relations between elements

More information

TABLES AND HASHING. Chapter 13

TABLES AND HASHING. Chapter 13 Data Structures Dr Ahmed Rafat Abas Computer Science Dept, Faculty of Computer and Information, Zagazig University arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ TABLES AND HASHING Chapter 13

More information

Hash Table and Hashing

Hash Table and Hashing Hash Table and Hashing The tree structures discussed so far assume that we can only work with the input keys by comparing them. No other operation is considered. In practice, it is often true that an input

More information

Algorithms and Data Structures

Algorithms and Data Structures Lesson 4: Sets, Dictionaries and Hash Tables Luciano Bononi http://www.cs.unibo.it/~bononi/ (slide credits: these slides are a revised version of slides created by Dr. Gabriele D Angelo)

More information

SFU CMPT Lecture: Week 8

SFU CMPT Lecture: Week 8 SFU CMPT-307 2008-2 1 Lecture: Week 8 SFU CMPT-307 2008-2 Lecture: Week 8 Ján Maňuch E-mail: jmanuch@sfu.ca Lecture on June 24, 2008, 5.30pm-8.20pm SFU CMPT-307 2008-2 2 Lecture: Week 8 Universal hashing

More information

Data Structures and Algorithms. Chapter 7. Hashing

Data Structures and Algorithms. Chapter 7. Hashing 1 Data Structures and Algorithms Chapter 7 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

Hashing. Hashing Procedures

Hashing. Hashing Procedures Hashing Hashing Procedures Let us denote the set of all possible key values (i.e., the universe of keys) used in a dictionary application by U. Suppose an application requires a dictionary in which elements

More information

Data Structures and Algorithms. Roberto Sebastiani

Data Structures and Algorithms. Roberto Sebastiani Data Structures and Algorithms Roberto Sebastiani roberto.sebastiani@disi.unitn.it http://www.disi.unitn.it/~rseba - Week 07 - B.S. In Applied Computer Science Free University of Bozen/Bolzano academic

More information

CS 270 Algorithms. Oliver Kullmann. Generalising arrays. Direct addressing. Hashing in general. Hashing through chaining. Reading from CLRS for week 7

CS 270 Algorithms. Oliver Kullmann. Generalising arrays. Direct addressing. Hashing in general. Hashing through chaining. Reading from CLRS for week 7 Week 9 General remarks tables 1 2 3 We continue data structures by discussing hash tables. Reading from CLRS for week 7 1 Chapter 11, Sections 11.1, 11.2, 11.3. 4 5 6 Recall: Dictionaries Applications

More information

Hashing Techniques. Material based on slides by George Bebis

Hashing Techniques. Material based on slides by George Bebis Hashing Techniques Material based on slides by George Bebis https://www.cse.unr.edu/~bebis/cs477/lect/hashing.ppt The Search Problem Find items with keys matching a given search key Given an array A, containing

More information

Fundamental Algorithms

Fundamental Algorithms Fundamental Algorithms Chapter 7: Hash Tables Michael Bader Winter 2011/12 Chapter 7: Hash Tables, Winter 2011/12 1 Generalised Search Problem Definition (Search Problem) Input: a sequence or set A of

More information

HashTable CISC5835, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Fall 2018

HashTable CISC5835, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Fall 2018 HashTable CISC5835, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Fall 2018 Acknowledgement The set of slides have used materials from the following resources Slides for textbook by Dr. Y.

More information

Week 9. Hash tables. 1 Generalising arrays. 2 Direct addressing. 3 Hashing in general. 4 Hashing through chaining. 5 Hash functions.

Week 9. Hash tables. 1 Generalising arrays. 2 Direct addressing. 3 Hashing in general. 4 Hashing through chaining. 5 Hash functions. Week 9 tables 1 2 3 ing in ing in ing 4 ing 5 6 General remarks We continue data structures by discussing hash tables. For this year, we only consider the first four sections (not sections and ). Only

More information

Understand how to deal with collisions

Understand how to deal with collisions Understand the basic structure of a hash table and its associated hash function Understand what makes a good (and a bad) hash function Understand how to deal with collisions Open addressing Separate chaining

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 2. O(n) 2. [1 pt] What is the solution to the recurrence T(n) = T(n/2) + n, T(1)

More information

Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ.! Instructor: X. Zhang Spring 2017

Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ.! Instructor: X. Zhang Spring 2017 Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ.! Instructor: X. Zhang Spring 2017 Acknowledgement The set of slides have used materials from the following resources Slides

More information

Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ. Acknowledgement. Support for Dictionary

Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ. Acknowledgement. Support for Dictionary Algorithms with numbers (2) CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Spring 2017 Acknowledgement The set of slides have used materials from the following resources Slides for

More information

Hashing. Dr. Ronaldo Menezes Hugo Serrano. Ronaldo Menezes, Florida Tech

Hashing. Dr. Ronaldo Menezes Hugo Serrano. Ronaldo Menezes, Florida Tech Hashing Dr. Ronaldo Menezes Hugo Serrano Agenda Motivation Prehash Hashing Hash Functions Collisions Separate Chaining Open Addressing Motivation Hash Table Its one of the most important data structures

More information

CS 241 Analysis of Algorithms

CS 241 Analysis of Algorithms CS 241 Analysis of Algorithms Professor Eric Aaron Lecture T Th 9:00am Lecture Meeting Location: OLB 205 Business HW5 extended, due November 19 HW6 to be out Nov. 14, due November 26 Make-up lecture: Wed,

More information

Acknowledgement HashTable CISC4080, Computer Algorithms CIS, Fordham Univ.

Acknowledgement HashTable CISC4080, Computer Algorithms CIS, Fordham Univ. Acknowledgement HashTable CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang Spring 2018 The set of slides have used materials from the following resources Slides for textbook by Dr.

More information

DATA STRUCTURES/UNIT 3

DATA STRUCTURES/UNIT 3 UNIT III SORTING AND SEARCHING 9 General Background Exchange sorts Selection and Tree Sorting Insertion Sorts Merge and Radix Sorts Basic Search Techniques Tree Searching General Search Trees- Hashing.

More information

Hash Tables. Reading: Cormen et al, Sections 11.1 and 11.2

Hash Tables. Reading: Cormen et al, Sections 11.1 and 11.2 COMP3600/6466 Algorithms 2018 Lecture 10 1 Hash Tables Reading: Cormen et al, Sections 11.1 and 11.2 Many applications require a dynamic set that supports only the dictionary operations Insert, Search

More information

HASH TABLES. Hash Tables Page 1

HASH TABLES. Hash Tables Page 1 HASH TABLES TABLE OF CONTENTS 1. Introduction to Hashing 2. Java Implementation of Linear Probing 3. Maurer s Quadratic Probing 4. Double Hashing 5. Separate Chaining 6. Hash Functions 7. Alphanumeric

More information

AAL 217: DATA STRUCTURES

AAL 217: DATA STRUCTURES Chapter # 4: Hashing AAL 217: DATA STRUCTURES The implementation of hash tables is frequently called hashing. Hashing is a technique used for performing insertions, deletions, and finds in constant average

More information

Let the dynamic table support the operations TABLE-INSERT and TABLE-DELETE It is convenient to use the load factor ( )

Let the dynamic table support the operations TABLE-INSERT and TABLE-DELETE It is convenient to use the load factor ( ) 17.4 Dynamic tables Let us now study the problem of dynamically expanding and contracting a table We show that the amortized cost of insertion/ deletion is only (1) Though the actual cost of an operation

More information

V Advanced Data Structures

V Advanced Data Structures V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,

More information

Hash Tables. Hash functions Open addressing. March 07, 2018 Cinda Heeren / Geoffrey Tien 1

Hash Tables. Hash functions Open addressing. March 07, 2018 Cinda Heeren / Geoffrey Tien 1 Hash Tables Hash functions Open addressing Cinda Heeren / Geoffrey Tien 1 Hash functions A hash function is a function that map key values to array indexes Hash functions are performed in two steps Map

More information

Hash Tables. Hashing Probing Separate Chaining Hash Function

Hash Tables. Hashing Probing Separate Chaining Hash Function Hash Tables Hashing Probing Separate Chaining Hash Function Introduction In Chapter 4 we saw: linear search O( n ) binary search O( log n ) Can we improve the search operation to achieve better than O(

More information

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion,

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion, Introduction Chapter 5 Hashing hashing performs basic operations, such as insertion, deletion, and finds in average time 2 Hashing a hash table is merely an of some fixed size hashing converts into locations

More information

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 Prof. John Park Based on slides from previous iterations of this course Today s Topics Overview Uses and motivations of hash tables Major concerns with hash

More information

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far Chapter 5 Hashing 2 Introduction hashing performs basic operations, such as insertion, deletion, and finds in average time better than other ADTs we ve seen so far 3 Hashing a hash table is merely an hashing

More information

16 Greedy Algorithms

16 Greedy Algorithms 16 Greedy Algorithms Optimization algorithms typically go through a sequence of steps, with a set of choices at each For many optimization problems, using dynamic programming to determine the best choices

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Prerequisites A seven credit unit course Replaced OHJ-2156 Analysis of Algorithms We take things a bit further than

More information

V Advanced Data Structures

V Advanced Data Structures V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,

More information

Tirgul 7. Hash Tables. In a hash table, we allocate an array of size m, which is much smaller than U (the set of keys).

Tirgul 7. Hash Tables. In a hash table, we allocate an array of size m, which is much smaller than U (the set of keys). Tirgul 7 Find an efficient implementation of a dynamic collection of elements with unique keys Supported Operations: Insert, Search and Delete. The keys belong to a universal group of keys, U = {1... M}.

More information

Today s Outline. CS 561, Lecture 8. Direct Addressing Problem. Hash Tables. Hash Tables Trees. Jared Saia University of New Mexico

Today s Outline. CS 561, Lecture 8. Direct Addressing Problem. Hash Tables. Hash Tables Trees. Jared Saia University of New Mexico Today s Outline CS 561, Lecture 8 Jared Saia University of New Mexico Hash Tables Trees 1 Direct Addressing Problem Hash Tables If universe U is large, storing the array T may be impractical Also much

More information

Data Structures And Algorithms

Data Structures And Algorithms Data Structures And Algorithms Hashing Eng. Anis Nazer First Semester 2017-2018 Searching Search: find if a key exists in a given set Searching algorithms: linear (sequential) search binary search Search

More information

Dictionaries and Hash Tables

Dictionaries and Hash Tables Dictionaries and Hash Tables Nicholas Mainardi Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it 14th June 2017 Dictionaries What is a dictionary? A dictionary

More information

Hash Tables and Hash Functions

Hash Tables and Hash Functions Hash Tables and Hash Functions We have seen that with a balanced binary tree we can guarantee worst-case time for insert, search and delete operations. Our challenge now is to try to improve on that...

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS LECTURE 11 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 9-10... Hash tables ADT Stack ADT Queue ADT Deque ADT Priority Queue Hash tables Today Hash tables 1 Hash

More information

General Idea. Key could be an integer, a string, etc e.g. a name or Id that is a part of a large employee structure

General Idea. Key could be an integer, a string, etc e.g. a name or Id that is a part of a large employee structure Hashing 1 Hash Tables We ll discuss the hash table ADT which supports only a subset of the operations allowed by binary search trees. The implementation of hash tables is called hashing. Hashing is a technique

More information

15.4 Longest common subsequence

15.4 Longest common subsequence 15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible

More information

Introducing Hashing. Chapter 21. Copyright 2012 by Pearson Education, Inc. All rights reserved

Introducing Hashing. Chapter 21. Copyright 2012 by Pearson Education, Inc. All rights reserved Introducing Hashing Chapter 21 Contents What Is Hashing? Hash Functions Computing Hash Codes Compressing a Hash Code into an Index for the Hash Table A demo of hashing (after) ARRAY insert hash index =

More information

Hash Tables. Hash functions Open addressing. November 24, 2017 Hassan Khosravi / Geoffrey Tien 1

Hash Tables. Hash functions Open addressing. November 24, 2017 Hassan Khosravi / Geoffrey Tien 1 Hash Tables Hash functions Open addressing November 24, 2017 Hassan Khosravi / Geoffrey Tien 1 Review: hash table purpose We want to have rapid access to a dictionary entry based on a search key The key

More information

HO #13 Fall 2015 Gary Chan. Hashing (N:12)

HO #13 Fall 2015 Gary Chan. Hashing (N:12) HO #13 Fall 2015 Gary Chan Hashing (N:12) Outline Motivation Hashing Algorithms and Improving the Hash Functions Collisions Strategies Open addressing and linear probing Separate chaining COMP2012H (Hashing)

More information

Hashing HASHING HOW? Ordered Operations. Typical Hash Function. Why not discard other data structures?

Hashing HASHING HOW? Ordered Operations. Typical Hash Function. Why not discard other data structures? HASHING By, Durgesh B Garikipati Ishrath Munir Hashing Sorting was putting things in nice neat order Hashing is the opposite Put things in a random order Algorithmically determine position of any given

More information

CSE 214 Computer Science II Searching

CSE 214 Computer Science II Searching CSE 214 Computer Science II Searching Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Introduction Searching in a

More information

Lecture 7: Efficient Collections via Hashing

Lecture 7: Efficient Collections via Hashing Lecture 7: Efficient Collections via Hashing These slides include material originally prepared by Dr. Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole. 1 Announcements Lab 6 due Friday Lab 7 out tomorrow

More information

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5.

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5. 5. Hashing 5.1 General Idea 5.2 Hash Function 5.3 Separate Chaining 5.4 Open Addressing 5.5 Rehashing 5.6 Extendible Hashing Malek Mouhoub, CS340 Fall 2004 1 5. Hashing Sequential access : O(n). Binary

More information

Hashing. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong

Hashing. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong Department of Computer Science and Engineering Chinese University of Hong Kong In this lecture, we will revisit the dictionary search problem, where we want to locate an integer v in a set of size n or

More information

Hashing. October 19, CMPE 250 Hashing October 19, / 25

Hashing. October 19, CMPE 250 Hashing October 19, / 25 Hashing October 19, 2016 CMPE 250 Hashing October 19, 2016 1 / 25 Dictionary ADT Data structure with just three basic operations: finditem (i): find item with key (identifier) i insert (i): insert i into

More information

Fast Lookup: Hash tables

Fast Lookup: Hash tables CSE 100: HASHING Operations: Find (key based look up) Insert Delete Fast Lookup: Hash tables Consider the 2-sum problem: Given an unsorted array of N integers, find all pairs of elements that sum to a

More information

Symbol Table. Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management

Symbol Table. Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management Hashing Symbol Table Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management In general, the following operations are performed on

More information

Algorithms in Systems Engineering ISE 172. Lecture 12. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 12. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 12 Dr. Ted Ralphs ISE 172 Lecture 12 1 References for Today s Lecture Required reading Chapter 5 References CLRS Chapter 11 D.E. Knuth, The Art of Computer

More information

Hashing. Manolis Koubarakis. Data Structures and Programming Techniques

Hashing. Manolis Koubarakis. Data Structures and Programming Techniques Hashing Manolis Koubarakis 1 The Symbol Table ADT A symbol table T is an abstract storage that contains table entries that are either empty or are pairs of the form (K, I) where K is a key and I is some

More information

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.) CSE 0 Name Test Spring 006 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

HASH TABLES. Goal is to store elements k,v at index i = h k

HASH TABLES. Goal is to store elements k,v at index i = h k CH 9.2 : HASH TABLES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM JORY DENNY AND

More information

Hashing. Introduction to Data Structures Kyuseok Shim SoEECS, SNU.

Hashing. Introduction to Data Structures Kyuseok Shim SoEECS, SNU. Hashing Introduction to Data Structures Kyuseok Shim SoEECS, SNU. 1 8.1 INTRODUCTION Binary search tree (Chapter 5) GET, INSERT, DELETE O(n) Balanced binary search tree (Chapter 10) GET, INSERT, DELETE

More information

Data and File Structures Chapter 11. Hashing

Data and File Structures Chapter 11. Hashing Data and File Structures Chapter 11 Hashing 1 Motivation Sequential Searching can be done in O(N) access time, meaning that the number of seeks grows in proportion to the size of the file. B-Trees improve

More information

Data Structures and Algorithm Analysis (CSC317) Hash tables (part2)

Data Structures and Algorithm Analysis (CSC317) Hash tables (part2) Data Structures and Algorithm Analysis (CSC317) Hash tables (part2) Hash table We have elements with key and satellite data Operations performed: Insert, Delete, Search/lookup We don t maintain order information

More information

HASH TABLES.

HASH TABLES. 1 HASH TABLES http://en.wikipedia.org/wiki/hash_table 2 Hash Table A hash table (or hash map) is a data structure that maps keys (identifiers) into a certain location (bucket) A hash function changes the

More information

Hashing 1. Searching Lists

Hashing 1. Searching Lists Hashing 1 Searching Lists There are many instances when one is interested in storing and searching a list: A phone company wants to provide caller ID: Given a phone number a name is returned. Somebody

More information

Hashing. 1. Introduction. 2. Direct-address tables. CmSc 250 Introduction to Algorithms

Hashing. 1. Introduction. 2. Direct-address tables. CmSc 250 Introduction to Algorithms Hashing CmSc 250 Introduction to Algorithms 1. Introduction Hashing is a method of storing elements in a table in a way that reduces the time for search. Elements are assumed to be records with several

More information

( D. Θ n. ( ) f n ( ) D. Ο%

( D. Θ n. ( ) f n ( ) D. Ο% CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j

More information

31.6 Powers of an element

31.6 Powers of an element 31.6 Powers of an element Just as we often consider the multiples of a given element, modulo, we consider the sequence of powers of, modulo, where :,,,,. modulo Indexing from 0, the 0th value in this sequence

More information

18.3 Deleting a key from a B-tree

18.3 Deleting a key from a B-tree 18.3 Deleting a key from a B-tree B-TREE-DELETE deletes the key from the subtree rooted at We design it to guarantee that whenever it calls itself recursively on a node, the number of keys in is at least

More information

) $ f ( n) " %( g( n)

) $ f ( n)  %( g( n) CSE 0 Name Test Spring 008 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to compute the sum of the n elements of an integer array is: # A.

More information

CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course

CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course Today s Topics Review Uses and motivations of hash tables Major concerns with hash tables Properties Hash function Hash

More information

Hash Open Indexing. Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1

Hash Open Indexing. Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1 Hash Open Indexing Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1 Warm Up Consider a StringDictionary using separate chaining with an internal capacity of 10. Assume our buckets are implemented

More information

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1. Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik D. Demaine and Charles E. Leiserson Quiz 1 Quiz 1 Do not open this quiz booklet until you

More information

COSC160: Data Structures Hashing Structures. Jeremy Bolton, PhD Assistant Teaching Professor

COSC160: Data Structures Hashing Structures. Jeremy Bolton, PhD Assistant Teaching Professor COSC160: Data Structures Hashing Structures Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Hashing Structures I. Motivation and Review II. Hash Functions III. HashTables I. Implementations

More information

15.4 Longest common subsequence

15.4 Longest common subsequence 15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible

More information

BBM371& Data*Management. Lecture 6: Hash Tables

BBM371& Data*Management. Lecture 6: Hash Tables BBM371& Data*Management Lecture 6: Hash Tables 8.11.2018 Purpose of using hashes A generalization of ordinary arrays: Direct access to an array index is O(1), can we generalize direct access to any key

More information

Hash Table. A hash function h maps keys of a given type into integers in a fixed interval [0,m-1]

Hash Table. A hash function h maps keys of a given type into integers in a fixed interval [0,m-1] Exercise # 8- Hash Tables Hash Tables Hash Function Uniform Hash Hash Table Direct Addressing A hash function h maps keys of a given type into integers in a fixed interval [0,m-1] 1 Pr h( key) i, where

More information

Lecture 16. Reading: Weiss Ch. 5 CSE 100, UCSD: LEC 16. Page 1 of 40

Lecture 16. Reading: Weiss Ch. 5 CSE 100, UCSD: LEC 16. Page 1 of 40 Lecture 16 Hashing Hash table and hash function design Hash functions for integers and strings Collision resolution strategies: linear probing, double hashing, random hashing, separate chaining Hash table

More information

Data Structures - CSCI 102. CS102 Hash Tables. Prof. Tejada. Copyright Sheila Tejada

Data Structures - CSCI 102. CS102 Hash Tables. Prof. Tejada. Copyright Sheila Tejada CS102 Hash Tables Prof. Tejada 1 Vectors, Linked Lists, Stack, Queues, Deques Can t provide fast insertion/removal and fast lookup at the same time The Limitations of Data Structure Binary Search Trees,

More information

1. Attempt any three of the following: 15

1. Attempt any three of the following: 15 (Time: 2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written

More information

Lecture 4. Hashing Methods

Lecture 4. Hashing Methods Lecture 4 Hashing Methods 1 Lecture Content 1. Basics 2. Collision Resolution Methods 2.1 Linear Probing Method 2.2 Quadratic Probing Method 2.3 Double Hashing Method 2.4 Coalesced Chaining Method 2.5

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17 5.1 Introduction You should all know a few ways of sorting in O(n log n)

More information

Hashing 1. Searching Lists

Hashing 1. Searching Lists Hashing 1 Searching Lists There are many instanced when one is interested in storing and searching a list: phone company wants to provide caller ID: Given a phone number a name is returned. Somebody who

More information

Cpt S 223. School of EECS, WSU

Cpt S 223. School of EECS, WSU Hashing & Hash Tables 1 Overview Hash Table Data Structure : Purpose To support insertion, deletion and search in average-case constant t time Assumption: Order of elements irrelevant ==> data structure

More information

Data Structures. Topic #6

Data Structures. Topic #6 Data Structures Topic #6 Today s Agenda Table Abstract Data Types Work by value rather than position May be implemented using a variety of data structures such as arrays (statically, dynamically allocated)

More information

More on Hashing: Collisions. See Chapter 20 of the text.

More on Hashing: Collisions. See Chapter 20 of the text. More on Hashing: Collisions See Chapter 20 of the text. Collisions Let's do an example -- add some people to a hash table of size 7. Name h = hash(name) h%7 Ben 66667 6 Bob 66965 3 Steven -1808493797-5

More information

CS 303 Design and Analysis of Algorithms

CS 303 Design and Analysis of Algorithms Mid-term CS 303 Design and Analysis of Algorithms Review For Midterm Dong Xu (Based on class note of David Luebke) 12:55-1:55pm, Friday, March 19 Close book Bring your calculator 30% of your final score

More information

Question Bank Subject: Advanced Data Structures Class: SE Computer

Question Bank Subject: Advanced Data Structures Class: SE Computer Question Bank Subject: Advanced Data Structures Class: SE Computer Question1: Write a non recursive pseudo code for post order traversal of binary tree Answer: Pseudo Code: 1. Push root into Stack_One.

More information

Jana Kosecka. Linear Time Sorting, Median, Order Statistics. Many slides here are based on E. Demaine, D. Luebke slides

Jana Kosecka. Linear Time Sorting, Median, Order Statistics. Many slides here are based on E. Demaine, D. Luebke slides Jana Kosecka Linear Time Sorting, Median, Order Statistics Many slides here are based on E. Demaine, D. Luebke slides Insertion sort: Easy to code Fast on small inputs (less than ~50 elements) Fast on

More information

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is: CS 124 Section #8 Hashing, Skip Lists 3/20/17 1 Probability Review Expectation (weighted average): the expectation of a random quantity X is: x= x P (X = x) For each value x that X can take on, we look

More information

CSCI Analysis of Algorithms I

CSCI Analysis of Algorithms I CSCI 305 - Analysis of Algorithms I 04 June 2018 Filip Jagodzinski Computer Science Western Washington University Announcements Remainder of the term 04 June : lecture 05 June : lecture 06 June : lecture,

More information

CS 310 Hash Tables, Page 1. Hash Tables. CS 310 Hash Tables, Page 2

CS 310 Hash Tables, Page 1. Hash Tables. CS 310 Hash Tables, Page 2 CS 310 Hash Tables, Page 1 Hash Tables key value key value Hashing Function CS 310 Hash Tables, Page 2 The hash-table data structure achieves (near) constant time searching by wasting memory space. the

More information

Successful vs. Unsuccessful

Successful vs. Unsuccessful Hashing Search Given: Distinct keys k 1, k 2,, k n and collection T of n records of the form (k 1, I 1 ), (k 2, I 2 ),, (k n, I n ) where I j is the information associated with key k j for 1

More information

Randomized Algorithms, Hash Functions

Randomized Algorithms, Hash Functions Randomized Algorithms, Hash Functions Lecture A Tiefenbruck MWF 9-9:50am Center 212 Lecture B Jones MWF 2-2:50pm Center 214 Lecture C Tiefenbruck MWF 11-11:50am Center 212 http://cseweb.ucsd.edu/classes/wi16/cse21-abc/

More information

Lecture 17. Improving open-addressing hashing. Brent s method. Ordered hashing CSE 100, UCSD: LEC 17. Page 1 of 19

Lecture 17. Improving open-addressing hashing. Brent s method. Ordered hashing CSE 100, UCSD: LEC 17. Page 1 of 19 Lecture 7 Improving open-addressing hashing Brent s method Ordered hashing Page of 9 Improving open addressing hashing Recall the average case unsuccessful and successful find time costs for common openaddressing

More information

Tables. The Table ADT is used when information needs to be stored and acessed via a key usually, but not always, a string. For example: Dictionaries

Tables. The Table ADT is used when information needs to be stored and acessed via a key usually, but not always, a string. For example: Dictionaries 1: Tables Tables The Table ADT is used when information needs to be stored and acessed via a key usually, but not always, a string. For example: Dictionaries Symbol Tables Associative Arrays (eg in awk,

More information

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1 CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each t. What is the value of k? k=0 A. k B. t C. t+ D. t+ +. Suppose that you have

More information

Direct File Organization Hakan Uraz - File Organization 1

Direct File Organization Hakan Uraz - File Organization 1 Direct File Organization 2006 Hakan Uraz - File Organization 1 Locating Information Ways to organize a file for direct access: The key is a unique address. The key converts to a unique address. The key

More information