Definition of a Hash Table Hosh tables aro good for doing a quick search on things. For instance It we have an array tull of data (say 100 items). if we knew the position that a specific item is stored in an array, then we could quickly access it. For instance, we just happen to know that the item we want it is at position 3, We can apply myitem=myaray|3]: With this, we don't have to search through aach element in the array, we just access position 3. The queation is, hew do we know that pasition 3 stores the data that we are nterested in? This is where hashing comes in handy.
Definition of a Hash Table Hosh tables aro good for doing a quick search on things. For instance It we have an array tull of data (say 100 items). if we knew the position that a specific item is stored in an array, then we could quickly access it. For instance, we just happen to know that the item we want it is at position 3, We can apply myitem=myaray|3]: With this, we don't have to search through aach element in the array, we just access position 3. The queation is, hew do we know that pasition 3 stores the data that we are nterested in? This is where hashing comes in handy.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![Definition of a Hash Table
Hash tables aro good for doinga quick
search on things.
For instance if we have an array tuli of
data (say 100 items). If we knew the
pasition that a specific item is stored in
an array, then we could quickly access it.
For instance, we just happen to know that
the item we want it is at position 3, We
can apply.
myitem=myaray[3]:
With this, we don't have to search through
sach element in the array, we just access
position 3.
The question is, how do we know that
pasition 3 stores the data that we gre
interested in?
This is where hashing comes in handy.
Given some key. we can apply o hash
function to it to find an index or position
that we wont to acces.
What is the hash function?
There are many different hosh functions.
Some hash funotions will take an integer
key and turn it into an index. A common
one is the dlivision method.
Let's learn through an example
Divislon method (one hash
method for integers)
Let's say you hod the following numbers
or keys that you wanted to mop into an
cirray of 10 elements:
123458
123467
123450
To apply the division methad, you couldi
divide the number by 10 (or the maximum
number of elements in the array) and use
the remainder (the modulo) as an index
The fallowing would result:
123456 % 10 = 6 (the remainder is 6 when
dividing by 10)
123467 X 10 = 7 (the remainder is 7)
123450 % 10 = 0 (the remainder is 0)
These numbers would be inserted into
the array at positions 6, 7, and 0
respectively.
A problem occurs when two keys yield
the same Index. For Instance, say we
wanted to include:
123467 X 10 = 7 (the remainder is 7)
123457 % 10 = 7 (the remainder is 7)
We have a collision becauso 123467s is
already stored at array index 7.
We need a method to resolve this using
Linear Probing : We search sequentially
for the next empty location
You have to write a code to create
a Hash table to store student ids
188262
182105
187795
197709
198219
186623
195409
190738
189797
186653
,use as Hashing function
account Id%table size. Define
function that will resolve collision
(LUnear ).](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc32ff3a2-55b3-4539-bca0-c449ee5dac92%2F042d1273-cb80-48a0-8675-3488d7522d06%2Fx4jc7w_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Definition of a Hash Table
Hash tables aro good for doinga quick
search on things.
For instance if we have an array tuli of
data (say 100 items). If we knew the
pasition that a specific item is stored in
an array, then we could quickly access it.
For instance, we just happen to know that
the item we want it is at position 3, We
can apply.
myitem=myaray[3]:
With this, we don't have to search through
sach element in the array, we just access
position 3.
The question is, how do we know that
pasition 3 stores the data that we gre
interested in?
This is where hashing comes in handy.
Given some key. we can apply o hash
function to it to find an index or position
that we wont to acces.
What is the hash function?
There are many different hosh functions.
Some hash funotions will take an integer
key and turn it into an index. A common
one is the dlivision method.
Let's learn through an example
Divislon method (one hash
method for integers)
Let's say you hod the following numbers
or keys that you wanted to mop into an
cirray of 10 elements:
123458
123467
123450
To apply the division methad, you couldi
divide the number by 10 (or the maximum
number of elements in the array) and use
the remainder (the modulo) as an index
The fallowing would result:
123456 % 10 = 6 (the remainder is 6 when
dividing by 10)
123467 X 10 = 7 (the remainder is 7)
123450 % 10 = 0 (the remainder is 0)
These numbers would be inserted into
the array at positions 6, 7, and 0
respectively.
A problem occurs when two keys yield
the same Index. For Instance, say we
wanted to include:
123467 X 10 = 7 (the remainder is 7)
123457 % 10 = 7 (the remainder is 7)
We have a collision becauso 123467s is
already stored at array index 7.
We need a method to resolve this using
Linear Probing : We search sequentially
for the next empty location
You have to write a code to create
a Hash table to store student ids
188262
182105
187795
197709
198219
186623
195409
190738
189797
186653
,use as Hashing function
account Id%table size. Define
function that will resolve collision
(LUnear ).
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY