# TDDC32 Tryout Exam

```TDDC32 Tryout Exam
Rules:
•
•
•
•
•
•
No materials allowed
A total of 21 points can be opbtained. For a grade of 3 the number of points required is
11. For a grade of 4 it’s 14 and for a grade of 5 it’s 17.
For every assignment you get 3 points. If there are 2 subassinments per assignment you
get 1.5 points per subassinment. If there are 3 subassinments then you get 1 point per
subassinment.
Note that the number of assignments and the points per assignment may change in the
real exam.
The problem 7 is to be added .
Happy exercising
Assignments:
1. Describe 2 principles of OOAD
2. What is a method signature and how does it relate to polymorphism?
2) UML
1. What are use case diagrams and where are they used?
2. What is the similarity and difference between a sequence diagram and a collaboration
diagram
3) AVL trees
1. Construct an AVL tree, when the following values, arriving in the following order: 9 6 7
2 1 11 10 3 8 4 5:
2. What is a FIBONACCI tree and why is it important?
4) Splay trees:
1. What is the advantage of using splay trees over AVL trees?
2. Show, step by step how a removal of the value 5 occurs in the following splay tree:
1
2
7
6
5
3
4
5) Hashtables
1. Why/when does one want to increase the size of a hashtable?
2. For a hashtable of size 11 the primary hash function is h(k) = k % 11. Choose a dual hash
function d(k), explain your choice if different from the standard one, and insert: 11 76 22
44 91 84 47 75 14 55. Show the final hashtable, h(k), d(k), and the probed locations in
the hashtable for all the values to be inserted.
6) Skip Lists &amp; Heaps
1. What is the advantage of skip lists over lists implemented with a) arrays b) linked lists with
respect to find() and insert()?
2. How many children can a node have in a heap and what is the heap order property?
7) (a,b) Trees
1. Show what happens step by step when you remove the values 20, 3 from the following (2,5)
tree.
20
10
3
6
30
18
23 26
27
40
50
33 39
42
44
53
56
2. Show what happens step by step when you add the values 62, 63, 24, 25 to the following
(2,5) tree:
59
20
10
3
6
30
18
23 26
27
40
50
33 39
42
44
53
56
59
3. Show that when you have a split of an (inner) node in an (a, b) tree, the number of children
of any of the 2 resulting nodes is larger than the minimum number of children allowed.
A node is splitted if it has at least b+1 children. As we promote he median key, the smaller of the nodes
resulting in the split will have the number of children, denoted here as c as follows. If b is odd then c =
(b+1)/2. If b is even then c = b / 2. From the definition of (a,b) trees we know that a ≤ (b+1)/2. Now if b
is odd then it’s immediately visible that c ≥ a. If b is even then a ≤ b/2, so again c ≥ a.
q.e.d.
```