Kocaeli University Faculty of Engineering Department of Software
Engineering 2022-2023 Spring Semester
08.06.2023
YZM210 Algorithm Analysis Final Exam
Name & Surname:
Time allocated : 70 minutes
Student Number:
Signature:
GOOD LUCK…
Dr. Mehmet Zeki Konyar
QUESTIONS:
Q1. What is the execution time of these functions? Write for each line and total codes (10p).
Q2. Write complexity of the following examples for big-Oh [O( )] notation. Assume the “n” is big
enough (10p).
Equation
a)
20𝑛3 + 10𝑛 𝑙𝑜𝑔 𝑛 + 5
b)
3 𝑙𝑜𝑔 𝑛 + 𝑙𝑜𝑔 𝑙𝑜𝑔 𝑛
c)
2100
d)
5𝑛 𝑙𝑜𝑔 𝑛 + 2𝑛
Q3. Solve the complexity of the following recurrences with Master Method. When you select any case
of Master Method also write the reason (15p).
Recurrence
a)
𝑇(𝑛) = 3𝑇(𝑛/2) + 𝑛
b)
𝑇(𝑛) = 4𝑇(𝑛/2) + 𝑐𝑛
c)
𝑇(𝑛) = 6𝑇(𝑛/3) + 𝑛2 𝑙𝑜𝑔 𝑛
d)
𝑇(𝑛) = 3𝑇(𝑛/3) + 𝑛/2
e)
𝑇(𝑛) = 𝑇(𝑛/2) + 2𝑛
Q4. Write the pseudocode of the Insertion Sort algorithm and sort S array with insertion sort method.
S[ ]= {89, 45, 68, 90, 29, 34, 17}. Show all steps for sorting of S array. (10p)
Q5. Sort the n-element character array S with divide and conquer algorithm based Quick sort method.
S[ ]= {T, U, R, K, I, Y, E}. Select the first element as pivot and show all steps for sorting of S array
(10p)
Q6. Using quadratic probing for hash function “h(t) = t mod 15”, insert the 44, 31, 29, 144, 157 into the
empty hash table. Show all details for each element. (Hint: k = h(k) and f(x) = k + x2). (15p)
index
0
1
2
47
3
4
5
35
6
36
7
8
9
129
10
25
11
2501
12
13
14
65
Q7. For the given query interval [12,14], search for each interval in the following interval tree set that
overlaps [12,14] or not. Write your calculation details and write the return value. (10p)
Final return value:
Q8 (15p). Given two sequences x=[ K, L, M, L, N, K, L] and y=[L, N, M, K, L, K], find a longest
subsequence with memoization method common to them both. (Compute the table bottom-up and use
a table as large as you need) (20p)
1