Docsity

CS 245 Final Exam – Winter 2017, Exams of Network Technologies and TCP/IP

Toggle sidebar
bg1
CS 245
Final Exam – Winter 2017
This exam is open book and notes. You can use a calculator and your laptop to access course
notes and videos (but not to communicate with other people or to browse the Internet). You have
180 minutes to complete the exam.
Best of luck!!!
Print your name:
The Honor Code is an undertaking of the students, individually and collectively:
1. that they will not give or receive aid in examinations; that they will not give or receive
unpermitted aid in class work, in the preparation of reports, or in any other work that is to
be used by the instructor as the basis of grading;
2. that they will do their share and take an active part in seeing to it that others as well as
themselves uphold the spirit and letter of the Honor Code.
The faculty on its part manifests its confidence in the honor of its students by refraining from
proctoring examinations and from taking unusual and unreasonable precautions to prevent the
forms of dishonesty mentioned above. The faculty will also avoid, as far as practicable, academic
procedures that create temptations to violate the Honor Code.
While the faculty alone has the right and obligation to set academic requirements, the students
and faculty will work together to establish optimal conditions for honorable academic work.
I acknowledge and accept the Honor Code.
Signed:
Problem Points Maximum
1 10
2 10
3 10
4 10
5 10
6 10
7 20
Total 80
Please note: Problem 7 (true/false) is worth 20 points.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download CS 245 Final Exam – Winter 2017 and more Exams Network Technologies and TCP/IP in PDF only on Docsity!

CS 245

Final Exam – Winter 2017

This exam is open book and notes. You can use a calculator and your laptop to access course notes and videos (but not to communicate with other people or to browse the Internet). You have 180 minutes to complete the exam.

Best of luck!!!

Print your name:

The Honor Code is an undertaking of the students, individually and collectively:

  1. that they will not give or receive aid in examinations; that they will not give or receive unpermitted aid in class work, in the preparation of reports, or in any other work that is to be used by the instructor as the basis of grading;
  2. that they will do their share and take an active part in seeing to it that others as well as themselves uphold the spirit and letter of the Honor Code.

The faculty on its part manifests its confidence in the honor of its students by refraining from proctoring examinations and from taking unusual and unreasonable precautions to prevent the forms of dishonesty mentioned above. The faculty will also avoid, as far as practicable, academic procedures that create temptations to violate the Honor Code.

While the faculty alone has the right and obligation to set academic requirements, the students and faculty will work together to establish optimal conditions for honorable academic work.

I acknowledge and accept the Honor Code.

Signed:

Problem Points Maximum 1 10 2 10 3 10 4 10 5 10 6 10 7 20 Total 80 Please note: Problem 7 (true/false) is worth 20 points.

Problem 1: Recovery (10 Points)

Consider a database with two elements, X and Y. The initial values of X and Y are both 0. We consider three transactions U, V and W that modify these elements concurrently:

  • T 1 : X := 42
  • T 2 : Y := 20, X := 10
  • T 3 : X := 100, Z := 101

While the transactions execute, the database system crashes. We consider three recovery mechanisms in turn below; your task is to first complete the missing parts of the log and then answer the following questions:

(a) Using pure undo logging:

1. < ST ART T 2 >

2. < ST ART T 3 >

3. < T 2 , X, 0 >

4. < T 2 , Y, 0 >

5. < COM M IT T 2 >

6. < ST ART CKP T (T 3 ) >

7. < T 3 , X, ??? >

8. < ST ART T 1 >

9. < T 3 , Z, 0 >

10. < T 1 , X, ??? >

(i) Please complete the undo log by providing in the appropriate values for the log below:

Line 6:

Line 10:

(ii) If the database crashes immediately after writing the above log entries, then subse- quently performs recovery, which of the following statements is true: A. After a successful recovery, the state of Y is 0.

(b) Using pure redo logging:

1. < ST ART T 2 >

2. < ST ART T 3 >

3. < T 2 , X, 10 >

4. < T 2 , Y, 20 >

5. < COM M IT T 2 >

6. < ST ART CKP T (T 3 ) >

7. < T 3 , X, ??? >

8. < ST ART T 1 >

9. < T 3 , Z, ??? >

10. < T 1 , X, 42 >

11. < EN D CKP T >

12. < COM M IT T 3 >

13. < ST ART CKP T (T 1 ) >

14. < COM M IT T 1 >

(i) Line 7:

Line 9:

(ii) If the database crashes immediately after writing the above log entries, then subse- quently performs recovery, which of the following statements is true: A. After a successful recovery, the state of X is 100. B. At the time of crash, the state of X (on disk) must be 42. C. At the time of crash, the state of Y (on disk) must be 20. D. After a successful recovery, the state of Z is 0.

True statement (one of A, B, C, or D):

C

(c) Using undo-redo logging, with log format (txn, item, before-val, after-val):

1. < ST ART T 1 >

2. < ST ART T 2 >

3. < ST ART T 3 >

4. < T 3 , X, 0 , 100 >

5. < T 3 , Z, 0 , 101 >

6. < COM M IT T 3 >

7. < T 2 , X, 100 , 10 >

8. < ST ART CKP T (T 1 , T 2 ) >

9. < T 2 , Y, ???, ??? >

10. < EN D CKP T >

11. < ST ART CKP T (T 1 , T 2 ) >

12. < COM M IT T 2 >

13. < T 1 , X, ???, ??? >

(i) Please complete the undo-redo log by providing in the appropriate values for the log below:

Line 9:

Line 13:

(ii) If the database crashes immediately after writing the above log entries, which of the following statements is true: A. During recovery, the log entry in line 4 will be redone. B. During recovery, the log entry in line 7 will be ignored. C. During recovery, the log entry in line 9 will be ignored. D. During recovery, the log entry in line 13 will be undone.

True statement (one of A, B, C, or D):

B

(c) R 3 (B)R 2 (A)R 1 (A)R 2 (C)W 3 (A)W 2 (B)W 1 (C)

(d) W 1 (A)W 2 (B)W 1 (B)W 2 (A)

Solutions:

(a) R 1 (A)W 2 (B)R 2 (A)W 1 (B)W 3 (B)W 1 (C)R 3 (B)W 1 (A)

T 1 T 2

T 3

Conflict serializable, equivalent to T 2 T 1 T 3

(b) W 2 (C)R 1 (A)W 3 (B)R 1 (C)R 3 (B)R 3 (A)W 2 (B)W 1 (B)

T 1 T 2

T 3

Conflict serializable, equivalent to T 3 T 2 T 1

(c) R 3 (B)R 2 (A)R 1 (A)R 2 (C)W 3 (A)W 2 (B)W 1 (C)

T 1 T 2

T 3

Not conflict serializable due to R 3 (B) before W 2 (B) and R 2 (A) before W 3 (A).

(d) W 1 (A)W 2 (B)W 1 (B)W 2 (A)

T 1 T 2

Not conflict serializable due to W 1 (A) before W 2 (A) and W 2 (B) before W 1 (B).

The following 5 transactions execute under a validation concurrency control protocol:

  • T 1 : Read Set: {B, E}, Write Set: {C, E, G}
  • T 2 : Read Set: {G}, Write Set: {A, B}
  • T 3 : Read Set: {A}, Write Set: {C}
  • T 4 : Read Set: {A, C}, Write Set: {B, D}
  • T 5 : Read Set: {G}, Write Set: {C, D}

Consider the following sequence of events:

  1. T 1 starts
  2. T 2 starts
  3. T 2 begins validation
  4. T 1 begins validation
  5. T 3 starts
  6. T 2 finishes validation
  7. T 4 starts
  8. T 5 starts
  9. T 4 begins validation
  10. T 1 finishes validation
  11. T 5 begins validation
  12. T 3 begins validation
  13. T 4 finishes validation
  14. T 3 finishes validation
  15. T 5 finishes validation

State which transactions validate successfully and which do not. If a transaction successfully validates, write “YES.” If not, write ‘NO” and state the conflict by stating the transactions that conflict, and which item(s) they conflict on (e.g., “T 1 and T 2 have a read-write conflict on F”).

(a) Does T 1 validate successfully? If not, state the conflict as instructed above. No. There is a read-write conflict on B between T 1 and T 2.

(b) Does T 2 validate successfully? If not, state the conflict as instructed above. Yes.

(c) Does T 3 validate successfully? If not, state the conflict as instructed above. No. There is a read-write conflict on A between T 3 and T 2.

(d) Does T 4 validate successfully? If not, state the conflict as instructed above. Yes.

(e) Does T 5 validate successfully? If not, state the conflict as instructed above. No. There is a write-write conflict on D between T 4 and T 5.

SIX(R),IX(A),IS(B),IX(t1),IS(t3),X(t1.E),S(t3.H) locks at the same level can be switched

(b) Consider the following four schedules, each with two transactions, U and V, executing under the multi-granularity locking system and database as above. Circle the schedules that can be be achieved under strict 2-phase locking. Below, wU (A) refers to write of table A by transaction U.

(i) rU (t 1 .E), wV (A), commit(U ), commit(V ) (ii) rV (A), wU (t3), rU (t1), commit(U ), commit(V ) (iii) wV (t1), rU (A), rV (A), commit(U ), commit(V ) (iv) wU (t1), rU (A), wV (t3), commit(U ), commit(V )

ii and iv should be circled.

(c) Consider the following index consisting of nodes N 1 through N 10 :

N

N

N

N

N5 N6 N

N

N9 N

What is the sequence of lock and unlock operations required to lock node 10? As above, provide your answer in the spaces below, with one lock or unlock operation per space pro- ceeding left to right (you need not use all the spaces provided). Only depict lock or unlock operations (no intention locks). For example: L(N 5 )U (N 5 )L(N 1 )U (N 1 )

L(N 4 )L(N 1 )L(N 10 )

hint: the above example is not correct.

L(N1); L(N2); U(N1); L(N3);

U(N1); L(N6); U(N3); L(N8);

U(N6); L(N10)

(a) Simulation when wait-die deadlock prevention is used:

Step T 1 T 2 T 3 1 L(B) L(A) L(C)

2 Wait Wait Die

3 L(C) Die Die

4 U(C) L(A) L(C)

5 U(B) Wait Die

6 L(C) Die

7 U(A) Die

8 U(C) Die

9 L(C)

10 L(B)

11 U(C)

12 U(B)

(b) Simulation when wound-wait deadlock prevention is used:

Step T 1 T 2 T 3 1 L(B) L(A) L(C)

2 L(C) Wait Die

3 U(C) L(C) Wait

4 U(B) U(A) Wait

5 U(C) L(C)

6 L(B)

7 U(C)

8 U(B)

Problem 6: Pre-Midterm Potpourri (10 Points)

(a) Query Processing I/Os: Consider performing a natural join operation on two relations R(A, B) and S(B, C). Assume that R contains 36000 records stored contiguously on 1800 disk blocks (i.e., B(R) = 1800; 20 tuples per block), and that S contains 1000 records stored non-contiguously and that each block of memory and disk can store 20 tuples of S.

(i) Suppose we have just two blocks of memory. Ignoring output I/Os, what is the minimum number of I/Os required to perform the natural join via a iteration join if use our two blocks of memory to store one block each of R and S in memory at a time?:

Since S is not stored contiguously, we should hold S in memory to avoid I/Os, then do multiple passes over R. We will read in S one memory block at a time, then join with R. We have 1000 /20 = 50 passes of R. Therefore, we have 1000 I/Os to read in S, and 20 ∗ 1800 I/Os to join with S. 37 , 000 I/Os total.

(ii) Suppose we have just enough memory to allow a two-pass hash join (not hybrid hash join!). Ignoring output I/Os, Using a two-pass hash join (as described in class notes 7, slides 61-64), what is the total number of I/Os required to perform the natural join via a hash join?:

Cost to read and write R = 1800 ∗ 2 = 3600. Cost to read and write S = 1000 + 50 =

  1. Read R1, R2 = 50 + 1800. Total: 6500

(b) Cardinality Estimation: Consider relations M (A, B), N (C, D), each containing 500 records.

(i) What is the expected number of records in [M ./ N ]?

(ii) Given a selection predicate B = 2 with expected selectivity 0. 01 (i.e., 1 in 100 records will match the predicate). What is the expected number of records in [σB=2M ./ N ]?

  1. 01 ∗ 500 ∗ 500 = 2500

(iii) Given a selection predicate B = 2 with expected selectivity 0. 01. What is the expected number of records in σB=2[M ./ N ]? 0. 01 ∗ 500 ∗ 500 = 2500

(iv) Given a selection predicate B = 2 with expected selectivity 0. 01 and a selection pred- icate C = 4 with expected selectivity 0. 1. What is the expected number of records in [σB=2M ./ σC=4N ]? 0. 01 ∗ 500 ∗ 500 = 250

(c) Storage Costs: Consider relation D(A, B, C) such that column A contains a 8 byte string, column B contains a 4 -byte floating point number, and column C contains a binary blob of up to 2048 bytes represented by a 2-byte header followed by the data. If we store D on a disk with block size 512 :

(i) What is the minimum number of blocks required to store 1000 records of D? (8 + 4 +

  1. ∗ 1000 / 512 = 28 blocks

(i) Ignoring the cost of additional headers required to mark records that span multiple blocks, what is the maximum number of blocks required to store 1000 records of D? (8 + 4 + 2 + 2048) ∗ 1000 / 512 = 4028 blocks