0% found this document useful (0 votes)
48 views3 pages

Extendable Hashing and B+-Tree Analysis

Part b answer key

Uploaded by

f20220123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Extendable Hashing and B+-Tree Analysis

Part b answer key

Uploaded by

f20220123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3. Assume we have a relation r(X, Y ) where the domain of X is letters, and the domain of Y is integers.

Assume we have a hash function on letters, where “A” hashes to (binary) 0100, where “B” hashes to 0101,
where “C” hashes to 0011, and where “D” hashes to 1101. Based on this hash function, we construct an
extendable hash structure by inserting the following records in the order shown:
(B,8), (D,4), (C,1), (A,7), (D,3), (D,9), (B,5).

Show the resulting extendable hash structure, assuming that each bucket can hold at most two pointers.
Also show at least two of the intermediate steps. [7]

We can insert (B, 8) and (D, 4) without extending the bucket address table.
To insert (C, 1), we need to double the size of the bucket address table. As
result, ’0’ will point to a bucket containing (B, 8) and (C, 1), and ’1’ point
to a bucket containing (D, 4).
To insert (A, 7), we need to double the size of the bucket address table. As
result, ’00’ will point to a bucket containing (C, 1), ’01’ will point to a bucket
containing (A, 7) and (B, 8), while ’10’ and ’11’ will now both point to the
bucket containing (D, 4).
In the latter bucket, there is room to insert the record (D, 3), but in order
to insert (D, 9).
Finally, we must insert (B, 5); since the bucket pointed to by ’01’ is already
full, and since it takes 4 bits to distinguish between the hash value of B and
the hash value of A, we need to double twice the size of the bucket address
table. As result, we get the following structure:
4. Consider a B+-tree of order two (d=2). Thus, the maximum number of pointers per node is 5 and the
maximum number of entries is 4.
(A) Show the results of entering one by one the keys that are three letter strings: (era, ban, bat, kin, day,
log, rye, max, won, ace, ado, bug, cop, gas, let, fax ) (in that order) to an initially empty B+-tree. Assume
that you use lexicographic ordering to compare the strings. Show the state of the tree after every 4
insertions.
(B) What is the utilization of the tree? The utilization of the tree is defined as the total number of entries in
all the nodes of the tree (both leaf and non-leaf nodes) over the maximum number of entries that the same
nodes can store.

[5+1=6]
5. Consider the following schedule:

(A) Show, by drawing the precedence graph, that the schedule is serializable or not, and list an equivalent serial
schedule.
(B) Argue that the above schedule can/cannot be generated by the two-phase locking protocol.
(C) Also argue that the above schedule will be/will not be accepted by the time stamp ordering protocol (where
T1 has a lower timestamp than T2 which has a lower timestamp then T3).
[2+2+2=6]

The precedence graph has an arrow from T3 to T1 (due to T3 accessing B


before T1 writes B), and an arrow from T1 to T2 (due to T1 writing A before
T2 accesses A). There are no other arcs, so the precedence graph is acyclic,
with a topological ordering (the only one possible) given by T3 < T1 <
T2. Hence the schedule is serializable,

and equivalent to the serial scheduleT3; T1; T2.

In a locking protocol, T1 needs to release the lock for A to T2 before line 4


(when T2 needs it), and must acquire the lock for B which is not available
until after line 6 (when T3 no longer needs it). This contradicts the twophase
restriction.

For the timestamp-ordering protocol, everything works well until the last
line, when T1 is not allowed to write B (and hence is aborted) since a higher
transaction, T3, has already written B.

You might also like