Answer to Assignment 2

Advanced Algorithm Analysis (CP5602)

Due Date: 2nd June 2019 at 11:59pm

Total: 20 marks

Aim: This assignment is designed to evaluate/improve your critical thinking and problem solving skills. It also evaluate/improve your coding skill.

1. For a tree T, let nI denote the number of its internal nodes, and let nE denote the number of its external nodes. Show that if every internal node in T has exactly 3 children, then nE = 2nI + 1.

[2 marks]

2. Insert entries with keys, 2, 7, 3, 12, 5, 20, 14, 6, 11, 8, 15, 17, 1, 19, 23, 14 (in this order), into an empty:

(a) heap. [1 mark]

(b) binary search tree. [1 mark]

(c) AVL tree. [1 mark]

(d) (2, 4) tree. [1 mark]

[4 marks] 3. Although merge sort runs in ????(n lg n) worst-case time and insertion sort runs in ????(n2) worst case time, the constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within merge sort when sub problems become sufficiently small. Consider a modification to merge sort in which n/k sub lists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined.

i) Show that the n/k sub lists, each of length k, can be sorted by insertion sort in ????(nk) worst-case time. [1 mark]

ii) Show that the sub lists can be merged in ????(n lg(n/k)) worst-case time. [2 marks] iii) Given that the modified algorithm runs in ????(nk + n lg(n/k)) worst-case time, what is the largest asymptotic (????-notation) value of k as a function of n for which the modified algorithm has the same asymptotic running time as standard merge sort. [2 marks] [5 marks]

4. Consider the recurrence T(n) = 3T(?n/2?) + n.

i) Use the master method to give tight asymptotic bound for this recurrence (if the master method cannot be used, explain why). [1 mark]

ii) Use a recursion tree to determine a good asymptotic upper bound on this recurrence.

[2 marks] iii) Use the substitution method to verify your answer. [1 mark]

[4 marks]

5. Show all the steps for performing any of the following algorithms for matching the pattern ‘rithm’ in the text ‘advancedalgorithmanalysis’.

(a) brute-force [1 mark]

(b) Boyer-Moore [2 mark]

(c) Knuth-Morris-Pratt [2 mark]

[5 marks]

Advanced Algorithm Analysis (CP5602)

Due Date: 2nd June 2019 at 11:59pm

Total: 20 marks

Aim: This assignment is designed to evaluate/improve your critical thinking and problem solving skills. It also evaluate/improve your coding skill.

1. For a tree T, let nI denote the number of its internal nodes, and let nE denote the number of its external nodes. Show that if every internal node in T has exactly 3 children, then nE = 2nI + 1.

[2 marks]

2. Insert entries with keys, 2, 7, 3, 12, 5, 20, 14, 6, 11, 8, 15, 17, 1, 19, 23, 14 (in this order), into an empty:

(a) heap. [1 mark]

(b) binary search tree. [1 mark]

(c) AVL tree. [1 mark]

(d) (2, 4) tree. [1 mark]

[4 marks] 3. Although merge sort runs in ????(n lg n) worst-case time and insertion sort runs in ????(n2) worst case time, the constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within merge sort when sub problems become sufficiently small. Consider a modification to merge sort in which n/k sub lists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined.

i) Show that the n/k sub lists, each of length k, can be sorted by insertion sort in ????(nk) worst-case time. [1 mark]

ii) Show that the sub lists can be merged in ????(n lg(n/k)) worst-case time. [2 marks] iii) Given that the modified algorithm runs in ????(nk + n lg(n/k)) worst-case time, what is the largest asymptotic (????-notation) value of k as a function of n for which the modified algorithm has the same asymptotic running time as standard merge sort. [2 marks] [5 marks]

4. Consider the recurrence T(n) = 3T(?n/2?) + n.

i) Use the master method to give tight asymptotic bound for this recurrence (if the master method cannot be used, explain why). [1 mark]

ii) Use a recursion tree to determine a good asymptotic upper bound on this recurrence.

[2 marks] iii) Use the substitution method to verify your answer. [1 mark]

[4 marks]

5. Show all the steps for performing any of the following algorithms for matching the pattern ‘rithm’ in the text ‘advancedalgorithmanalysis’.

(a) brute-force [1 mark]

(b) Boyer-Moore [2 mark]

(c) Knuth-Morris-Pratt [2 mark]

[5 marks]

This above price is for already used answers. Please do not submit them directly as it may lead to plagiarism. Once paid, the deal will be non-refundable and there is no after-sale support for the quality or modification of the contents. Either use them for learning purpose or re-write them in your own language. If you are looking for new unused assignment, please use live chat to discuss and get best possible quote.

ELEC2042 2020 Session 2 Assignment 2 (Version 2)Due: Friday 23rd October 2020Quadrature EncodersThe image below shows the disk for a quadrature encoder. This device creates a series of pulse strings when...ASSESSMENT GUIDEBUSN112: Managing Markets, Semester 2 2020Assessment 3Individual Market Analysis Business Report Weighting [40%] Why this assessment?This assessment provides you with the opportunity to...ASSESSMENT TASK 3 (in two parts)1. Create a piece of work that relates themes from the Book of the Year, This is my Song (for example, racism, persecution, trauma, hope etc.) to the CST principles. This...1200 wordASSESSMENT TASK 3 (in two parts) uncc100 creative task and written reflection; assessment of application skills in relation to LO1 and LO2: following the generation of a creative work, students...SampleASSESSMENT 2 BRIEFSubject Code and Title LAW 6001 Taxation LawAssessment Assessment 2: Case Study (Individual taxpayer’s tax return)Individual/Group IndividualLength For the Report 2000 words +/- 10% excluding...Online Discussion- Press FreedomDue: Thu, Oct 22 2020 at 11:59 PMEnumerate the cases presented by Presidential Spokesperson Harry Roque, UP Journalism Professor- Danilo Arao, and Political Scientist Richard...**Show All Questions**