Tentamen/Exam TDDC32 Design och implementering av programmodul i Java

advertisement
Tentamen/Exam
TDDC32 Design och implementering av programmodul i Java
TDDC32 Design and implementation of a software module in Java
2010–03–17
14.00 – 18.00
• No help materials are allowed, except for an English dictionary.
• You may answer in Swedish or English.
• Total number of credits is 23. Limits:
3: 11p, 4: 15, 5: 19p.
• Jour (person on duty): Jonas Wallgren
1
1
OOA&OOD
a)(1p) What is the input to the OOA?
b)(2p) What are the purpose and the main activities/products of the OOA?
c)(2p) What are the purpose and the main activities/products of the OOD?
2
UML
(3p) Describe the following situation using a class diagram:
A Motor-vehicle is a Vehicle.
A Manpowered-vehicle is a Vehicle.
A Big-vehicle is a Vehicle.
A Small-vehicle is a Vehicle.
A Car is a Big Motor-vehicle.
An MC is a Small Motor-vehicle.
A Bicycle is a Small Manpowered-vehicle.
A Small-vehicle has two Wheels.
A Big vehicle has four Wheels.
A Garage may contain any number of Vehicles.
2
3
AVL
a)(1.5p) Construct the AVL tree from the keys (in the given order) 1, 2, 3, 4, 5, 6, 7.
You only need to show the result after completing the insertion of 6 and the final tree.
b)(1.5p) Remove 20 from the following AVL tree. Draw the tree transformations step by step.
20
/\
/ \
/
/
\
\
10
30
/\
/\
/ \
/ \
7
14 25 35
/ \
/
/
3
9 12 22
/
1
4
Splay
Both of these subproblems use the splay tree given in a) as its starting-point.
Solving one subproblem doesn’t influence the other one.
a)(1.5p) Add the value 54 to the following splay tree. Show the transformations step by step.
20
/ \
10 30
/\ \
7 14 35
\
39
\
46
/\
41 55
b)(1.5p) Remove the value 41 from the splay tree above. Show the transformations step by step.
3
5
(a,b)-tree
a)(1.5p) What do a and b in “(a,b)-tree” mean? How are they related?
b)(1.5p) Construct a (2,3)-tree from the keys (in the given order) 1, 3, 5, 7, 6, 4, 2.
You only need to show the complete tree after all insertions are completed.
6
Hash
a)(2p) In a hashtable of size 13, using linear hashing, insert: 6, 20, 31, 4, 18, 55, 11, 17, 1, 36
in that given order. Describe where each element is placed and comment/explain why.
b)(1p) What is the complexity of introducing one piece of data into a very full hastable
using separate chaining? Explain.
7
Skip
(3p) Build a skip list for the elements 1, 3, 5, 7, 2, 4, 6, 8 in that order.
The results of the coin tossing are (H=head, T=tail) H, T, T, H, H, T, over and over again.
4
Download