At the beginning, the number of elements in a set of numbers to be stored in a computer system used to be not so large or having a wide range. Then, using a
simple table T [0, 1, ..., m − 1]called, direct-address table, could be used to store those numbers. As the situation became more and more complex, and a new idea came to be:
Definition
An associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of tuples {(key, value)}
This can bee seen in the example of dictionaries in any spoken language. The problem became more complex when the range of the possible values for the
keys at the tuples became unbounded. Therefore a new type of data structure is needed to avoid the sparsity problem in the data, the hash table.
At the beginning, the number of elements in a set of numbers to be stored in a computer system used to be not so large or having a wide range. Then, using a
simple table T [0, 1, ..., m − 1]called, direct-address table, could be used to store those numbers. As the situation became more and more complex, and a new idea came to be:
Definition
An associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of tuples {(key, value)}
This can bee seen in the example of dictionaries in any spoken language. The problem became more complex when the range of the possible values for the
keys at the tuples became unbounded. Therefore a new type of data structure is needed to avoid the sparsity problem in the data, the hash table.
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Kuntal Bhowmick
A Hash table is a data structure used for storing and retrieving data very quickly. Insertion of data in the hash table is based on the key value. Hence every entry in the hash table is associated with some key.
HASHING AND HASH FUNCTIONS, HASH TABLE REPRESENTATION, HASH FUNCTION, TYPES OF HASH FUNCTIONS, COLLISION, COLLISION RESOLUTION, CHAINING, OPEN ADDRESSING – LINEAR PROBING, QUADRATIC PROBING, DOUBLE HASHING
The presentation is an introduction the hash algorithm application, dealing with random data and sorting it for fast accessing and implications with normal hashing techniques.
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Kuntal Bhowmick
A Hash table is a data structure used for storing and retrieving data very quickly. Insertion of data in the hash table is based on the key value. Hence every entry in the hash table is associated with some key.
HASHING AND HASH FUNCTIONS, HASH TABLE REPRESENTATION, HASH FUNCTION, TYPES OF HASH FUNCTIONS, COLLISION, COLLISION RESOLUTION, CHAINING, OPEN ADDRESSING – LINEAR PROBING, QUADRATIC PROBING, DOUBLE HASHING
The presentation is an introduction the hash algorithm application, dealing with random data and sorting it for fast accessing and implications with normal hashing techniques.
Combines the better attributes of merge sort and insertion sort.
Like merge sort, but unlike insertion sort, running time is O(nlgn).
Like insertion sort, but unlike merge sort, sorts in place.
I am Nigel J. I am a Computer Network Assignment Expert at computernetworkassignmenthelp.com. I hold a Master's in Computer Science from, the University of Glasgow, UK. I have been helping students with their assignments for the past 15 years. I solve assignments related to Computer Networks.
Visit computernetworkassignmenthelp.com or email support@computernetworkassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Computer Network Assignment.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
2. Definition: the ideal table data structure is merely an
array of some fixed size, containing the elements.
Consist : an array and a mapping function
(known as hash function)
Used for performing insertion, deletion and lookup
on average in constant time.
2
4. Storage Space Storing k
Direct
Addressing
|U| Store in slot k
Hashing m Store in slot h(k)
Advantage: Requires less storage and runs in O(1)
time.
Comparison
4
6. How can we solve the problem of collisions?
Solution 1:Solution 1: ChainingChaining
Solution 2:Solution 2: Open addressingOpen addressing
6
7. Put all the elements that hash to same slot in a
linked list.
Worst case : All n keys hash to the same slot
resulting in a linked list of length n, running time:
O(n)
Best and AverageAverage time: O(1)
7
9. Assume simple uniform hashing: each key in table is
equally likely to be hashed to any slot
Given n keys and m slots in the table: the load factor
α = n/m = average # keys per slot
What will be the average cost of an unsuccessful
search for a key?
O(1+ α)
9
10. What will be the average cost of a successful
search?
A: O(1 + α/2) = O(1 + α)
10
11. So the cost of searching = O(1 + α)
If the number of keys n is proportional to the
number of slots in the table, what is α?
A: α = O(1)
◦ In other words, we can make the expected cost of
searching constant if we make α constant
11
12. Nature of keys
Hash functions
Division method
Multiplication method
Open Addressing (Linear and Quadratic probing,
Double hashing)
12
13. Most hash functions assume that universe of keys is
the set N = {0, 1, 2,…} of natural numbers
If keys are not N, ways to be found to interpret them
as N
A character key can be interpreted as an integer
expressed in suitable Radix notation.
13
14. Example: The identifier pt might be interpreted as a
pair of decimal integers (112, 116) as p = 112 and t
= 116 in ASCII notation. What is the problem?
Using a product/addition of ASCII codes is indifferent
to the order of characters
Solution: Using 128-radix notation this becomes
(112.128) + 116 = 14,452
14
15. A hash function is a mapping between a set of input
values (Keys) and a set of integers, known as hash
values.
Keys Hash values
Hash
function
15
16. Rule1: The hash value is fully determined by the data
being hashed.
Rule2: The hash function uses all the input data.
Rule3: The hash function uniformly distributes the
data across the entire set of possible hash values.
Rule4: The hash function generates very different
hash values for similar strings.
16
17. int hash(char *str, int table_size)
{
int sum=0;
//sum up all the characters in the string
for(;*str; str++)
sum+=*str
//return sum mod table_size
return sum%table_size;
}
17
18. Rule1: Satisfies, the hash value is fully determined
by the data being hashed, the hash value is just the
sum of all input characters.
Rule2: Satisfies, Every character is summed.
18
19. Rule3: Breaks, from looking at it, it is not obvious that it
doesn’t uniformly distribute the strings, but if you were to
analyze this function for larger input string, you will see
certain statistical properties which are bad for a hash
function.
Rule4: Breaks, hash the string “CAT”, now hash the
string “ACT”, they are the same, a slight variation in the
string should result in different hash values, but with this
function often they don’t.
19
21. The division method requires two steps.
1. The key must be transformed into an
integer.
2. The value must be telescoped into range
0 to m-1
21
22. We map a key k into one of the m slots by taking the
remainder of k divided by m, so the hash function is of
form
h(k)= k mod m
For example , if m=12, key is 100 then
h(k)=100 mod 12= 4.
Advantage?
22
23. M should not be a
power of 2, since if
m=2p
then h(k) is just
the p lowest order
bits of k.
Disadvantage!
Key Binary K mod 8
8 1000 0
7 111 7
12 1100 4
34 100010 2
56 111000 0
78 1001110 6
90 1011010 2
23 10111 7
45 101101 5
67 1000011 3 23
24. Unless it is known that probability
distribution on keys makes all lower order
p-bit patterns equally likely,
it is better to make the hash function
dependent on all the bits of the key.
24
25. Power of 10 should be avoided, if application deals
with decimal numbers as keys.
Good values of m are primes not close to the exact
powers of 2 (or 10).
25
26. Using a random real number ff in the range (0,1).
The fractional part of the product ff*key yields a number
in the range 0 to 1.
When this number is multiplied by m (hash table size),
the integer portion of the product gives the hash value
in the range 0 to m-1
26
27. Choose m = 2P
For a constant A, 0 < A < 1:
h(k) = m (kA - kA)
Value of A should not be close to 0 or 1
Knuth says good value of A is 0.618033
If k=123456, m=10000,and A as above
h(k)= 10000.(123456*A- 123456*A)
= 10000. (0.0041151)
=41
27
28. For mm ∈∈ (4, 15)(4, 15), and k = {contents first news item
www.dawn.com} and mapping function k mod
m, and other hash function given on slide-28,
plot histogram results using Excel. Contrast and
compare results on the basis of mm. June 15, 2010
08:59 am.
28
29. So far we have studied hashing with chaining, using a
linked-list to store keys that hash to the same location.
Maintaining linked lists involves using pointers which is
complex and inefficient in both storage and time
requirements.
Another option is to store all the keys directly in the table.
This is known as open addressing, where collisions are
resolved by systematically examining other table indexes, i 0 ,
i 1 , i 2 , … until an empty slot is located.
29
30. ◦ Another approach for collision resolution.
◦ All elements are stored in the hash table itself (so no
pointers involved as in chaining).
◦ To insert: if slot is full, try another slot, and another, until an
open slot is found (probing)
◦ To search, follow same sequence of probes as would be
used when inserting the element
30
31. The key is first mapped to a slot:
If there is a collision subsequent probes are
performed:
If the offset constant, c and m are not relatively
prime, we will not examine all the cells. Ex.:
◦ Consider m=4 and c=2, then only every other slot is
checked.
When c=1 the collision resolution is done as a linear
search. This is known as linear probing.
)(index 10 ki h==
0formod)(1 ≥+=+ jmcii jj
0 1 2 3
31
32. HASH_INSERT(T,k)
1 i ← 0
2 repeat j ← h(k,i)
3 if T[j] = NIL
4 then T[j] = k
5 return j
6 else i ← i +1
7 until i = m
8 error “ hash table overflow”
32
33. HASH_SEARCH(T,k)
1 i ← 0
2 repeat j ← h(k,i)
3 if T[j] = k
4 then return j
5 i ← i +1
6 until T[j] = NIL or i = m
7 return NIL
33
34. Worst case for inserting a key is θ(n)
Worst case for searching is θ(n)
34
35. 35
Whenever there is a collision, one strategy is to
look for the next unused slot and use it.
Linear Probing.
36. 36
When searching for an empty slot, one has to
remember to wrap around (like a circular array)
37. Even with a good hash function, linear probing has its problems:
◦ The position of the initial mapping i 0 of key k is called the home
position of k.
◦ When several insertions map to the same home position, they end up
placed contiguously in the table. This collection of keys with the same
home position is called a cluster.
◦ As clusters grow, the probability that a key will map to the middle of a
cluster increases, increasing the rate of the cluster’s growth. This
tendency of linear probing to place items together is known as
primary clustering.
◦ As these clusters grow, they merge with other clusters forming even
bigger clusters which grow even faster.
37
38. h(k,i) = (h’(k) + c1i + c2i 2
) mod m for i = 0,1,…,m − 1.
◦ Leads to a secondary clustering (milder form of clustering)
◦ The clustering effect can be improved by increasing the
order to the probing function (cubic). However the hash
function becomes more expensive to compute
38
39. Recall that in open addressing the sequence of probes follows
We can solve the problem of primary clustering in linear probing by having
the keys which map to the same home position use differing probe
sequences. In other words, the different values for c should be used for
different keys.
Double hashing refers to the scheme of using another hash function for c
0formod)(1 ≥+=+ jmcii jj
1)(0and0formod))(( 221 −≤<≥+=+ mkjmkii jj hh
39
40. Lecture is prepared using information from
Chapter 11 “Hash Tables” of book “Introduction to
Algorithms” By Thomas H. Cormen et al
Book is available in the library, make photocopy of
this chapter
40
41. 41
Compare hash based search with
Binary search on best case basis.
What value of load factor will result in
fewer collisions?