ArticleslgStudy

computer science

Linear hashing

Linear hashing is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Linear hashing rather than just read about it. In short: Linear hashing (LH) is a dynamic data structure which implements a hash table and grows or shrinks one bucket at a time. It was invented by Witold Litwin in 1980.

Key takeaways

  • Linear hashing belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Linear hashing to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Linear hashing from memory before moving on to harder problems.

Reference excerpt

Linear hashing (LH) is a dynamic data structure which implements a hash table and grows or shrinks one bucket at a time. It was invented by Witold Litwin in 1980. It has been analyzed by Baeza-Yates and Soza-Pollman. It is the first in a number of schemes known as dynamic hashing such as Larson's Linear Hashing with Partial Extensions, Linear Hashing with Priority Splitting, Linear Hashing with Partial Expansions and Priority Splitting, or Recursive Linear Hashing. The file structure of a dynamic hashing data structure adapts itself to changes in the size of the file, so expensive periodic file reorganization is avoided. A Linear Hashing file expands by splitting a predetermined bucket into two and shrinks by merging two predetermined buckets into one. The trigger for a reconstruction depends on the flavor of the scheme; it could be an overflow at a bucket or load factor (i.e., the number of records divided by the number of buckets) moving outside of a predetermined range. In Linear Hashing there are two types of buckets, those that are to be split and those already split. While extendible hashing splits only overflowing buckets, spiral hashing (a.k.a. spiral storage) distributes records unevenly over the buckets such that buckets with high costs of insertion, deletion, or retrieval are earliest in line for a split. Linear Hashing has also been made into a scalable distributed data structure, LH*. In LH*, each bucket resides at a different server. LH* itself has been expanded to provide data availability in the presence of failed buckets. Key based operations (inserts, deletes, updates, reads) in LH and LH* take maximum constant time independent of the number of buckets and hence of records.

Algorithm details Records in LH or LH* consists of a key and a content, the latter basically all the other attributes of the record. They are stored in buckets. For example, in Ellis' implementation, a bucket is a linked list of records. The file allows the key based CRUD operations create or insert, read, update, and delete as well as a scan operations that scans all records, for example to do a database select operation on a non-key attribute. Records are stored in buckets whose numbering starts with 0. The key distinction from schemes such as Fagin's extendible hashing is that as the file expands due to insertions, only one bucket is split at a time, and the order in which buckets are split is already predetermined.

Hash functions The hash function h i ( c ) {\displaystyle h_{i}(c)} returns the 0-based index of the bucket that contains the record with key c {\displaystyle c} . When a bucket which uses the hash function h i {\displaystyle h_{i}} is split into two new buckets, the hash function h i {\displaystyle h_{i}} is replaced with h i + 1 {\displaystyle h_{i+1}} for both of those new buckets. At any time, at most two hash functions h l {\displaystyle h_{l}} and h l + 1 {\displaystyle h_{l+1}} are used; such that l {\displaystyle l} corresponds to the current level. The family of hash functions h i ( c ) {\displaystyle h_{i}(c)} is also referred to as the dynamic hash function. Typically, the value of i {\displaystyle i} in h i {\displaystyle h_{i}} corresponds to the number of rightmost binary digits of the key c {\displaystyle c} that are used to segregate the buckets. This dynamic hash function can be expressed arithmetically as h i ( c ) ↦ ( c mod 2 i ) {\textstyle h_{i}(c)\mapsto (c{\bmod {2}}^{i})} . Note that when the total number of buckets is equal to one, i = 0 {\displaystyle i=0} .

Complete the calculations below to determine the correct hashing function for the given hashing key c {\displaystyle c} .

Split control Linear hashing algorithms may use only controlled splits or both controlled and uncontrolled splits. Controlled splitting occurs if a split is performed whenever the load factor, which is monitored by the file, exceeds a predetermined threshold. If the hash index uses controlled splitting, the buckets are allowed to overflow by using linked overflow blocks. When the load factor surpasses a set threshold, the split pointer's designated bucket is split. Instead of using the load factor, this threshold can also be expressed as an occupancy percentage, in which case, the maximum number of records in the hash index equals (occupancy percentage)*(max records per non-overflowed bucket)*(number of buckets). An uncontrolled split occurs when a split is performed whenever a bucket overflows, in which case that bucket would be split into two separate buckets. File contraction occurs in some LH algorithm implementations if a controlled split causes the load factor to sink below a threshold. In this case, a merge operation would be triggered which would undo the last split, and reset the file state.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Linear hashing

Start with the simplest possible case. Write down what Linear hashing claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Linear hashing before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Linear hashing ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Linear hashing

In research
Linear hashing appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Linear hashing in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Linear hashing is common in secondary-school and first-year university syllabi. It links to neighbouring topics Hashing, Search algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Linear hashing outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Linear hashing in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Linear hashing means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Linear hashing out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Linear hashing in simple terms?

Linear hashing (LH) is a dynamic data structure which implements a hash table and grows or shrinks one bucket at a time. It was invented by Witold Litwin in 1980.

Why does Linear hashing matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Linear hashing?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Linear hashing.

Tags

  • Hashing
  • Search algorithms

Keep exploring