Log Files - PowerPoint PPT Presentation

1 / 54
About This Presentation
Title:

Log Files

Description:

In general, the approach of Summing Components can be. extended to keys with m components. ... where N is a prime number, a and b are nonnegative integers ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 55
Provided by: theunivers97
Category:
Tags: files | log | nonnegative

less

Transcript and Presenter's Notes

Title: Log Files


1
Log Files
2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
O(n)
O(n)
O(n)
O(n)
6
Data Structure Exercises 16.1
7
Hash Tables
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
In general, the approach of Summing Components
can be extended to keys with m components.   Let
the key be k (x0, x1, , xm-1), we compute the
integer. We may use the following expression as
its hash code hash code
22
v(t) v(e) v(m) v(p) v(0) v(1)
23
Polynomial Hash Codes   In this approach, we
choose a constant a ? 1 and calculate
the integer value
where the key is k (x0, x1, , xm-2, xm-1).
24
A 9
A carefully chosen value of the constant a can
reduce the number of conflicts significantly.
Good values include 33, 37, 39, and 41 according
to some experimental studies.
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
where N is a prime number, a and b are
nonnegative integers randomly chosen at the time
when the compression function is determined so
that a mod N ? 0.   This method is more
sophisticated works better.
31
Collision-Handling Schemes   Recall that if there
is no collision, we can store the item (k, e) in
the bucket array cell Ah(k). However, collision
does occur time to time. In this case, two
different keys, k1 and k2 cause the hash function
to return a same value h(k1) h(k2).
Therefore we cannot store -the item directly in
Ah(k).   The two schemes to handle
collisions   1.       1. Separate
Chaining 2.       2. Open Addressing
32
Separate Chaining   In this approach, what stored
in Ah(k). is a reference to a sequence Sk
rather than the item. In turn, the items that
have the same hash function value k are all
stored in Sk .   The sequence Sk can be
implemented as a log file.
33
(No Transcript)
34
(No Transcript)
35
(No Transcript)
36
(No Transcript)
37
(No Transcript)
38
Data Structure Exercises 16.2
39
(No Transcript)
40
Linear Probing - A simple opening addressing
scheme   Assume that we want to insert an item
(k, e) and I h(k). The operation goes like
this If the bucket Ai is not empty, we try
the next bucket A(i1) mod N. If this is not
empty, then we try A(i2) mod N, and so on,
until we find an empty bucket. Example
41
(No Transcript)
42
(No Transcript)
43
(No Transcript)
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
One of disadvantages with Linear probing is that
it tends to cluster the items of the dictionary
into contiguous runs. This causes the searches to
slow down quite a bit. To avoid this, we can
use quadratic probing.   Quadratic
Probing   Rather than searching the buckets for
, we search the buckets A(i j) mod N for j
0, 1, 2, , we search the buckets A(i j2) mod
N.
48
(No Transcript)
49
Double Hashing   In this approach, we search the
buckets A(if(i)) mod N, where f(i) jh(k)
and h(k) is the secondary hash function. In
this approach, the secondary hash function is not
allowed to be zero. A common choice is     h(k)
q (k mod q) where q lt N is some prime
number, which can be divide by 1 and itself.
50
h(k) 6
51
Data Structure Exercises 17.1
52
The Ordered Dictionary ADT
53
(No Transcript)
54
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com