2009–06–12
08.00 – 12.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, endast telefonjour: 28 2682
1
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?
Describe the following situation using a class diagram (3p):
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
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 22 from the following AVL tree. Draw the tree transformations step by step.
20
/\
/
/
/ \
\
\
1
/
10
/\
/ \
30
/\
/ \
7 14 25 35
/ \ / /
3 9 12 22
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 38 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 46 form the splay tree above. Show the transformations step by step.
3
a)(1.5p) Show what happens step by step when you remove the values 39, 18, 50 from the following (2,4)-tree:
+----+
| 20 |
/
/
+----+
\
\
+----+
| 10 |
+----+
| |
+----+----+----+
| 30 | 40 | 50 |
+----+----+----+
/ | | \
+---+ +----+ +----+ +----+ +----+ +----+
| 3 | | 18 | | 23 | | 39 | | 44 | | 59 |
+---+ +----+ +----+ +----+ +----+ +----+ b)(1.5p) What is the maximum height of a (2,4)-tree with n nodes? (Explain your answer.)
a)(2p) In a hashtable using linear hashing of size 13 insert: 14, 43, 28, 66, 79, 19, 1, 21, 72, 29, 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 the hashtable?
In what situations are hashtables preferred to trees?
a)(2p) Describe how delete is done in a skip list.
b)(1p) What are the complexities of inserting and deleting one element in a skip list? Explain.
4