Hashing Techniques in Data Structures

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the result of $89 % 10$?

  • 9 (correct)
  • 1
  • 8
  • 0

Which value corresponds to $58 % 10$?

  • 2
  • 8 (correct)
  • 7
  • 9

Identify the value that is not a remainder when divided by 10 from the given options.

  • 9
  • 1 (correct)
  • 3
  • 0

Which of the following values represents the remainder of $49 % 10$?

<p>9 (B)</p> Signup and view all the answers

What remainder is obtained when $79$ is divided by $10$?

<p>9 (D)</p> Signup and view all the answers

What formula is used for collision resolution in linear probing?

<p>(key + 1) % length (A)</p> Signup and view all the answers

When using quadratic probing, how is the collision resolution calculated?

<p>(key + i²) % size (C)</p> Signup and view all the answers

In the example given for linear probing, what is the computed index for the key 79 when using the provided method?

<p>9 (A)</p> Signup and view all the answers

Which of the following statements about open addressing is true?

<p>Open addressing requires rehashing when a collision occurs. (D)</p> Signup and view all the answers

What is the size of the table used in the examples provided for the probing techniques?

<p>10 (B)</p> Signup and view all the answers

Flashcards

Linear Probing

A collision resolution technique in Hashing where if a slot is occupied, the next available slot after the original slot is searched for.

Quadratic Probing

A collision resolution technique in Hashing where if a slot is occupied, slots are searched for based on a quadratic pattern(i^2).

Hashing Collision

A situation in hashing where different keys map to the same index (slot) in a hash table.

Hash Table

A data structure that stores data in an array, indexed by the hashed key values.

Signup and view all the flashcards

Modulo 10 (remainder)

The modulo operation, represented by the % symbol, calculates the remainder of a division. 89 % 10 = 9 means when 89 is divided by 10, the remainder is 9

Signup and view all the flashcards

89 % 10 = 9

When 89 is divided by 10, the remainder is 9

Signup and view all the flashcards

18 % 10 = 8

When 18 is divided by 10, the remainder is 8

Signup and view all the flashcards

49 % 10 = 9

When 49 is divided by 10, the remainder is 9

Signup and view all the flashcards

58 % 10 = 8

When 58 is divided by 10, the remainder is 8

Signup and view all the flashcards

79 % 10 = 9

When 79 is divided by 10, the remainder is 9

Signup and view all the flashcards

Modulo operation

A mathematical operation. Given two numbers, it finds the remainder of one by dividing by the other.

Signup and view all the flashcards

Remainder

The amount left over when a number is divided by another number

Signup and view all the flashcards

50 % 10

Zero

Signup and view all the flashcards

G(59%10=9)

This represents a group or category labeled with 59 % 10 = 9

Signup and view all the flashcards

G(62%10=2)

This represents a group labeled with 62 when divided by 10 gives a remainder of 2

Signup and view all the flashcards

G(83%10=3)

This represents a group or category labeled with 83 % 10 = 3

Signup and view all the flashcards

Study Notes

Open Addressing, Closed Hashing

  • Linear Probing: Used in closed hashing. Calculates the next hash index by incrementing the original index.
  • Collision Handling: If a key's hash index is already occupied, the next available slot along the index array is used.
  • Example: For a hash table size of 10, if key 38 maps to index 8 and it's taken, probing moves to index 9, and so on.
  • Collision Formula: (key + i) % length, where 'i' is the probe number. This formula shows how to calculate a new index when collision occurs.

Quadratic Probing

  • Collision Resolution: Calculates the next hash index by incrementing the original index. If occupied, it tries the next index using a quadratic formula instead of a linear one.
  • Formula: (key + i * i) % size of table.
  • Example Application: Handles collisions more efficiently in hash tables compared to linear probing.

Double Hashing

  • Collision Resolution: Uses a secondary hash function to calculate the step size between collision probes.
  • Formula: h(key) = key % tableSize, g(key) = 1 + [(key/tableSize) % (tableSize - 1)]
  • Key Functions: It uses two independent hashing functions: one calculates the initial index and one determines the step size for probing.
  • Example Usage: Handles collisions by using sequences determined by a step size formula.

General Hashing

  • Hash Function: Computes an index from a key.
  • Hash Table: A data structure used to store data efficiently.
  • Collision: The situation when multiple keys generate the same index in a hash table.
  • Load Factor: The ratio of the number of keys in a hash table to the size of the table (number of slots).
  • Types: Closed and open addressing.
  • Possible Order Keys: Can check if an order of keys in a hash table is feasible after insertion.
  • Hash Types: Linear, Quadratic, Double Hashing (techniques for managing collisions in a hash table).

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser