0909.2547 - Simple implementation of deletion from...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Simple implementation of deletion from open-address hash table Maxim A. Kolosovskiy Altai State Technical University, Russia [email protected] Abstract Deletion from open-address hash table is not so easy as deletion from chained hash table, because in open-address table we can’t simply mark a slot containing deleted key as empty. Search for keys may become incorrect. The classical method to implement deletion is to mark slots in hash table by three values: “free”, “busy”, “deleted”. That method is easy to implement, but there are some disadvantages. In this article we consider alternative method of deletion keys, where we avoid using the mark “deleted”. The article contains the implementation of the method in Java. 1. Introduction Hash table is an effective data structure to store dynamic set. Hash tables support following operations with that set: addition new element into the set; searching element in the set; deletion element from the set. Under some assumptions, these operations can be executed in O(1). The simplest implementation of such data structure is an ordinary array, where k- th element corresponds to key k . Thus, we can execute all operations in O(1). It is impossible to use this implementation, if the total number of keys is large. We can reduce the amount of used memory, if instead of used key k as array index we use value of function h(k) . This function is called hash function , the value h(k) is called hash value of key k . Using of such functions is the main idea of hash tables. Thus, the size of array equals the number of possible values of hash function. There are many ways to construct a hash function, but in this article we will use very simple function: h(k) = |k % m| , where m – size of array. We’ve reduced the amount of memory, but have obtained the following problem. If we work with two or more keys, which have the same hash value, these keys map to the same cell in the array. Such situations are called collisions . There are two basic ways to implement hash tables to resolve collisions: chained hash table; open-address hash table....
View Full Document

This note was uploaded on 12/17/2011 for the course COMP 101 taught by Professor Maxima.kolosovskiy during the Spring '11 term at A.T. Still University.

Page1 / 6

0909.2547 - Simple implementation of deletion from...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online