ANKARA UNIVERSITY
COMPUTER ENGINEERING
COM2067/COM267
FINAL 200 m.
You need to place your answers into a single pdf file and upload them. Make sure
your answers are readable. Name your file as [Link].
Read the questions carefully. Do not write code for the answers. Use the methods
described in the lecture and mentioned in the slides for the solutions.
1. (10 p) Using the two different methods below, insert the given values to the hash table that can
contain at most 10 elements. For this question, simply fill in the table below.
(a) Linear Probing
Hash function: h(k)=k mod 10
(b) Quadratic Probing
Hash function:
h(k, i) = [h’(k) + c1*i + c2*i2] mod 10 (h’= k mod 10, c1=3, c2=1)
35, 46, 45, 50, 26, 12, 55, 17, 7
(a) (b)
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
2. (15 p) Insert the following integer keys into a red-black tree. Show the red-black tree after each
insertion that cause change in the tree.
24, 18, 43, 57, 90, 35, 60
3. (15 p) Extract the key with value 48 from the following binomial heap. Draw the produced
binomial heap after this operation. Show all of the steps of producing this binomial heap.
4. (15 p) Create a Huffman tree using the following uppercase letters. Assume that only those
letters are used in the text. Given values represent the estimated frequencies of each letter in a
paragraph. Using the created Huffman tree, specify a binary coding for each letter.
P S M Y K E A
4 6 8 9 12 14 16
5. (10 p) Construct a binary tree from the following traversal results. Describe the steps.
In-Order Traversal: 6 4 1 3 0 5 9 7 8 2
Pre-Order Traversal: 0 1 4 6 3 2 5 7 9 8
6. (15 p) Insert the following integer keys into an AVL tree. After each balancing (rotation)
operation, write which rotation you have performed and show the AVL tree.
50, 40, 25, 10, 15, 5, 45, 35, 20, 30
7. (10 p) Convert the given general tree into a binary tree. Show each step.
8. (10 p) Apply the following insert and delete operations on 2-3 tree. Show 2-3 tree after each
operation.
Insert 25, 15, 5, 30, 20, 35, 40
Delete 30