This preview shows pages 1–8. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSE 100 Midterm Examination
W.A. Burkhard October 28, 2004 The principle of honesty must be upheld if the integrity of scholarship is to be maintained by an
academic community. This means that all academic work will be done by the student to whom it is assigned, without unauthorized aid of any kind. 1. This is a closed book examination. One handwritten study sheet is allowed; others will be removed with penalty.
2. Please check the entire examination immediately to ensure that your copy has all eight pages.
3. Put your name on all pages of the examination.
4. All questions have equal mark value. 5. Neatness counts. 6. You must clearly show your work; take time to prepare a legible answer.
7. Good luck and have fun! 8. Your signed studysheet must be turned in with your examination. 9. Examinations written in pencil will not be considered for re—grade. 10. You may use a calculator. Laptops and cellphones are not allowed. SO L (A TLOA) name student identiﬁer 1 6.
2 7.
3 8.
4 9.
5 10. total Priority Queues — logical binomial queues name 1. The following binomial queue has been created by inserting 14 nodes into the structure; the priority of a data item is its position in alphabetical order. cat bee ape I dog
i 'a bat
P S gnu boa elk J Y yak sow rat
fox Which of the follow sequences could have created this structure:
a. elk, fox, yak, dog, ape, jay, bat, rat, boa, bee, cat, gnu, pig, sow. D yes or E n0. b. boa, bee, cat, gnu, pig, sow, elk, fox, yak, dog, ape, jay, bat, rat. [1 yes or c. ape, bat, bee, boa, cat, dog, elk, fox, gnu, jay, pig, rat, sow, yak. D yes or 3 lg
d. ape, bat, dog, elk, fox, jay, rat, yak, bee, boa, cat, gnu. pig, sow. D yes or IE no.
e. ape, bat, dog, elk, fox, jay, rat, yak, cat, gnu. pig, sow, boa, bee. D yes or m f. ape, bat, dog, elk, fox, jay, rat, yak, sow, pig. gnu, cat, boa, bee. [:l yes or 2. Continuing the above, What logical binomial queue results when the data item hog is inserted? kf°c “966 _ Cod' Clo? O~Pe—
/ P (3/1 3“? lead:
loom said N W‘l‘ Vat
X el k
5m Double hashing with passbits name 3. Insert the following sequence of key values into the empty table using double hashing with passbits. Your solution must show 9L1 passbit values in the table after the ﬁnal record is inserted. 012345678910 s: F T F T’T‘
2%3‘85’7‘H 62 49, 62, 24, 19, 41, 57, 38 .n passbits I
I
H Q.
0)
H
n) Use the “standard” double hashing start and step functions and show both values for each key as well as indicating which record ﬁrst changes the passbit from false to true. Key Start Step Passbit(s) first changed
from false to true 49 5‘ lo 62 7 3 24 1 5' 19 3 l 0 41 ‘5 2 $3 57 l «3 Z , ‘0) 7 38 5 q 5‘ Double hashing with passbits name . Write a C function to calculate and return the expected successful and unsuccessful search lengths for a table implemented with double hashing and one passbit per slot containing m records and 71 slots. Your
function is to return a Perform structure value. You may use the math library function log which calculates
the natural log of its double argument and sqrt which calculates the square root of its double argument as needed. typedef struct {
double successful, unsuccessful ; } Perform ; Perform calculate ( int 111 , int n ) {
den»le ammo» —.. (doubleAm/vx °, Pal}:ka I: 3
P.5UVLL95S'FWQ : — i'o/“lpka ﬁx: ’a‘Pka) 3
PMVxSuccessltull 1‘ iIO/((i—alpka\*(1—Q03(1‘6~lpl\°~l))} few/MP3 Brent hashing name 5. Insert, in the order shown, the following sequence of key values into the empty table using Brent hashing.
Use the “standard” start and step functions for double hashing. Show your work especially that leading to selection of the record(s) to be moved. Key Start Step
49 5 10
62 3
24 5" 19 27
38 '7
Z
3
41 8
5'
5. 2.7; 4?; l+ I 4—. CAN’T BEM’ ’DHSJ Miscellaneous name 6. A threedimensional integer triangular array X with 0 3 2'0 < 1'1 < i2 < 12 is implemented in C using
the array int X[10] [11] [12]. How much space, measured in integers, will never contain anything in this approach? X SPACE NC; IzHdo s I320 “+5. Xsmce New» 21219.: 220 “*3
6 Space NEUEQ CozvrAwwcr MYTH/Na— l37/OLLO ; \100 in—t—g p“ 7. A list contains four elements with access probabilities 0.2, 0.3, 0.4, and 0.1; what is largest possible expected
number of accesses within a move to the front implementation of the list. Eon— : 0H + 2:0.3 + 30.1 + (#0,!
= Z EMTF 9; '1‘... l :7 3 Double hashing analysis name A table, containing n slots, implemented with double hashing currently contains m records. 821 What is the probability a slot is empty? 0< :3 l(«l/Vs, probabzlit’ﬁ a» s/o+ is eta/‘94:? is 1’0(. 8.b What is the expected number of probes7 via double hashing, to locate an empty slot? Lu 1 NMW‘BE/a 0F “P943391 1—0 pm.“
RF/M‘A—i Ag {EA/VPr—y (OPEN) SLOf’ ProhiLM=iY = 04‘2V1(1’d) V‘ .
EELu] : Z 'zwvoki 0(1—1
i=1 Binary tree hashing name A table containing 23 slots is implemented using binary tree hashing. During the insert operation for item
K, the following portion of the binary tree is created; the node marked empty designates the ﬁrst empty node ®
q 9. What records are moved to insert K according to binary tree hashing. 51,0? ‘6 LS Pouvo 77) ’13P, EMPTY. encountered. Move macaw IN sw‘r 5’ 72> 51,07' ‘8, Now: macaw IN SLOT l“ 77) 5L” 3' 10. What is the incremental cost of inserting K via binary tree hashing? Describe the methodology to obtain the incremental cost.
‘THE NumeeQ 0F M00135 oco ’ME PAW
'TO THE N009, 'DEKIGA/A/mvdcr AN EMPTY
51,07 (5 "THE, [NCJeJF/WENTAL C057— H£RE ’17“; INCA/ENNpr 6057' 1.5 5—: ...
View
Full
Document
This note was uploaded on 01/31/2010 for the course CSE 100 taught by Professor Staff during the Winter '08 term at UCSD.
 Winter '08
 staff

Click to edit the document details