Exercises
Exercises
1
8. The summation σ𝑛𝑖=1 evaluates to …
𝑖
Sort? Comment.
4- Fill in the spaces using one of the asymptotic notation (𝑂, Ω, Θ) for each sentence:
1) 2𝑛3 + 10𝑛 + 100 = ⋯ (𝑛3 )
2) 𝑛 lg 𝑛 = ⋯ (𝑛2 )
𝑛2
3) 𝑙𝑔𝑛 = ⋯ (𝑛2 )
4) 𝑛 lg 𝑛 + 𝑛 = ⋯ (𝑛)
Exercises
2- What are the average running times of Insertion-sort and Merge-
Sort? Comment.
4- Fill in the spaces using one of the asymptotic notation (𝑂, Ω, Θ) for each sentence:
1) 2𝑛3 + 10𝑛 + 100 = ⋯ (𝑛3 )
2) 𝑛 lg 𝑛 = ⋯ (𝑛2 )
𝑛2
3) 𝑙𝑔𝑛 = ⋯ (𝑛2 )
4) 𝑛 lg 𝑛 + 𝑛 = ⋯ (𝑛)
5- Explain briefly the main idea of counting sort.
6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2
8- Show all passes (iterations) when using Radix sort to sort the
following input:
9- What is the running time of Radix sort? (general formula and best-case).
Exercises
1) Write the recurrence describing the binary search. Discuss the best-
case and average-case running times.
2) Given the set of values: {3, 15, 10, 8, 12, 9, 18, 6, 2, 7}.
1) How can you apply Binary search?
2) How many comparisons will take place when searching for a value 11?
2) How many comparisons will take place when searching for a value 5?