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
2009–03–17
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 26. Limits:
3: 13p, 4: 17, 5: 22p.
• Jour (person on duty): Jonas Wallgren.
1
1
OOA&OOD
Explain what is ment in OOA and OOD by the following concepts/”slogans”:
a)(1.5p) Divide and conquer
b)(1.5p) Iterate and increment
c)(1.5p) Reuse and recycle
d)(1.5p) Strong cohesion and low coupling
2
UML
Describe the following situation using a class diagram (3p):
A Mammal is an Animal.
A Bird is Animal.
A Wild animal is an Animal.
A Domestic aninmal is an Animal.
A Rabbit is a Wild Mammal.
A Hen is a Domestic Bird.
A Fox is a Wild Mammal.
An Eagle is a Wild Bird.
All Birds have 2 legs.
All Mammals have 4 legs.
Predatory animals are animals.
Preys are animals.
All Predatory animals can have several possible Preys and some specific favourite Prey.
(Eagles prey on Foxes and Hens, and Foxes prey on Hens.)
2
3
AVL
a)(2p) Construct an AVL tree from the keys (in the given order) 4 6 9 11 5 3 10 8 7.
You don’t need to draw every intermediate tree. Every time there has been a rebalancing
you should draw the resulting tree.
b)(1p)What is a Fibonacci tree and what is it used for?
4
Splay
a)(2p) Construct a splay tree from the keys (in the given order) 4 6 9 11 5 3.
You don’t need to draw every intermediate tree. After an insert is completed together
with its tree rebuildings you should draw the resulting tree.
b)(1p) When is a splay tree better than an AVL tree and why is it better?
5
(a,b)-tree
a)(1p) What is a and b in “(a,b)-tree”? How are they related?
b)(2p) Construct a (2,3)-tree from the keys (in the given order) 4 5 6 7 1 2 3.
You only need to show the complete tree after all insertions are completed.
3
6
Hash
a)(1p) Describe separate chaining.
b)(1p) Describe linear probing.
c)(1p) Describe quadratic probing.
d)(1p) Describe double hashing.
e)(1p) The methods described in a)-d) are various methods to solve a problem in
hash list handling. Describe the problem.
7
Skip
a)(2p) Describe how insert is done in a skip list.
b)(1p) Arrays can be implemented using e.g. arrays or linked lists. What is the advantage of
skip lists over lists implemented with
i) arrays
ii) linked lists
when doing find and insert?
4
Download