Answer to Assignment 2 Advanced Algorithm Analysis (CP5602)
Reply to Task 2 Superior Algorithm Evaluation (CP5602) Due Date: 2nd June 2019 at 11:59pm Whole: 20 marks Goal: This project is designed to judge/enhance your crucial considering and downside fixing abilities. It additionally consider/enhance your coding talent. 1. For a tree T, let nI denote the variety of its inner nodes, and let nE denote the variety of its exterior nodes. Present that if each inner node in T has precisely three youngsters, then nE = 2nI + 1. [2 marks] 2. Insert entries with keys, 2, 7, three, 12, 5, 20, 14, 6, 11, eight, 15, 17, 1, 19, 23, 14 (on this order), into an empty: (a) heap. [1 mark] (b) binary search tree. [1 mark] (c) AVL tree. [1 mark] (d) (2, four) tree. [1 mark] [4 marks] three. Though merge type runs in 𝜃𝜃(n lg n) worst-case time and insertion type runs in 𝜃𝜃(n2 ) worst case time, the fixed elements in insertion type make it sooner for small n. Thus, it is sensible to make use of insertion type inside merge type when sub issues change into small enough. Think about a modification to merge type through which n/okay sub lists of size okay are sorted utilizing insertion type after which merged utilizing the usual merging mechanism, the place okay is a price to be decided. i) Present that the n/okay sub lists, every of size okay, will be sorted by insertion type in 𝜃𝜃(nk) worst-case time. [1 mark] ii) Present that the sub lists will be merged in 𝜃𝜃(n lg(n/okay)) worst-case time. [2 marks] iii) Provided that the modified algorithm runs in 𝜃𝜃(nk + n lg(n/okay)) worst-case time, what's the largest asymptotic (𝜃𝜃-notation) worth of okay as a perform of n for which the modified algorithm has the identical asymptotic working time as customary merge type. [2 marks] [5 marks] four. Think about the recurrence T(n) = 3T(⌊n/2⌋) + n. i) Use the grasp methodology to provide tight asymptotic sure for this recurrence (if the grasp methodology can't be used, clarify why). [1 mark] ii) Use a recursion tree to find out an excellent asymptotic higher sure on this recurrence. [2 marks] iii) Use the substitution methodology to confirm your reply. [1 mark] [4 marks] 5. Present all of the steps for performing any of the next algorithms for matching the sample ‘rithm’ within the textual content ‘advancedalgorithmanalysis’. (a) brute-force [1 mark] (b) Boyer-Moore [2 mark] (c) Knuth-Morris-Pratt [2 mark] [5 marks]