- Field Assignment #3
- Timetable_EOY 2011_ as at 20 Sept 2011
- 10.1.1.23
- Recursion Trees and Master Method
- MasterTheorem Handout
- MS-NDCSSelfEvalForm
- Long Wave
- How Vedic Math Benefits Everyone - School Board
- Big-O Algorithm Complexity Cheat Sheet
- Manual Freefem
- fem4
- homework 25-05 - 29- 05
- 02 Fundamentals of the Analysis of Algorithm Efficiency
- GATE Question
- Brochure
- xcvcbcb
- newsletter march 9-13
- correct math ed assignment 3
- thanksfromdror
- curriculum conference
- day 3 math resources b
- Starting School in IDR - Parent Meeting June 2014
- Vinay Pandey
- Study-Planner-For-Board-Examinations[1].pdf
- communication letters
- reviewgames
- grade 1 mathematics overview
- period 3 window 1
- all benchmarks
- MENG 3705 Project and Assessment - Spring 2015
- DAU.pdf
- BS Annexure
- hello (1)
- New Text Document

Due Date: 10th February, 2017

**1. (a) (5 points) Consider the following algorithm.
**

1: procedure isprime(n)

2:

3: if n==0 OR n==1 then

4: return F alse

5:

6: ARRAY A[n] = [1, ..., 1] . Initialized to all ones. Index starts at 0

7: i=2

8:

√

9: while i ≤ 2 n do

10: j=2

11: while i ∗ j ≤ n do

12: A[i ∗ j − 1] ← 0

13: j ←j+1

14: i←i+1

15: if A[n − 1] == 1 then

16: return T rue

17: else

18: return F alse

Find the time complexity of the above algorithm in the O() notation. Show your work.

(b) (7 points) Consider the following two subroutines:

- combine(A, B, C) takes 3 arrays A, B, C as input and returns an array as output.

- newSort(X) takes an array X as input and returns an array as output.

1: procedure combine(A, B, C) 1: procedure newSort(X)

2: 2:

3: i ← 0, j ← 0, k ← 0, t ← 0 3: if size(X) > 1 then

4: Initialize an array Y 4: newSort(X[0, . . . , n/3])

5: while i + j + k < n do 5: newSort(X[n/3 + 1, . . . , 2n/3])

6: if (A[i] ≤ B[j]) & (A[i] ≤ C[k]) then 6: newSort(X[2n/3 + 1, . . . , n − 1])

7: Y [t] ← A[i] 7: combine(X[0, . . . , n/3], X[n/3 +

8: i←i+1 1, . . . , 2n/3], X[2n/3 + 1, . . . , n − 1])

9: if i = size(A) then

10: A[i] ← ∞

11: else

12: if (B[j] < A[i]) & (B[j] ≤ C[k]) then

13: Y [t] ← B[j]

14: j ←j+1

15: if j = size(B) then

16: B[j] ← ∞

17: else

18: Y [t] ← C[k]

19: k ←k+1

20: if k = size(C) then

21: C[k] ← ∞

22: t←t+1

23: return Y

Write a recursion for the time complexity of the algorithm newSort. Solve the recursion to find the

time complexity of newSort in the O() notation.

2. (12 points) Compare and order the asymptotic growth order of the following functions in ascending order.

Mention explicitly if any two functions are equivalent or if they cannot be compared. For each function

f (n) in the list below, what is the best function class O(g(n)) such that f (n) ∈ O(g(n))?

.5. say A and B. . Y = (10. y2 . ( As X = (10. . . if A is a better player than B. then A will defeat B in any match played between them irrespective of any factors. Prove the correctness of your algorithm. chooses a sequence X such the value of C is maximum. . (13 points) X = (x1 . . x2 .for any three players. xn ) and Y = (y1 . (13 points) Give an algorithm to design a tournament consisting of n players so as to correctly identify the top three players in the tournament. Then your algorithm should output 17.before the tournament no information is known about the players. i=2 Design an O(n) algorithm that given the sequence Y as input.1. between any two players we can always say one of them is better than the other. The algorithm needs to output only the value of the maximum such C. if A defeats (is better than) B and B defeats (is better than) C then A can be assumed to defeat (be better than) C. What is the minimum number of matches that such a tournament must have (as a function of n)? Assume the following: . .9).9) is a valid sequence that maximizes the sum C ). say A.for any two players. .7. . yn ) are two sequences of n positive integers each such that 1 ≤ xi ≤ yi for all 1 ≤ i ≤ n.1.no match ever ends in a draw.1.5. Example 2: n=4. See the following examples: Example 1: Y = (10. such that the number of matches is minimized in the tournament. . Let X n C= |xi − xi−1 |. Then your algorithm should output 29. .1.9).5. ( As X= (10. B and C.7.3. i.9) is a valid sequence that maximizes the sum C ) 4. (i) 4 × 2n/2 (ii) en (iii) 500n2 − 3n + 2 (iv) n! (v) n2 + n + 2000 (vi) n log n (vii) n ln n (viii) n log(log(log n)) √ (ix) n (x) 2n n (xi) sin n (xii) nn 3. .e.

- Field Assignment #3Uploaded byengoj35
- Timetable_EOY 2011_ as at 20 Sept 2011Uploaded byWinson Chua
- 10.1.1.23Uploaded byErik Zepka
- Recursion Trees and Master MethodUploaded byHarsh Vardhan Jha
- MasterTheorem HandoutUploaded byvaibhav0071
- MS-NDCSSelfEvalFormUploaded byjudeansari
- Long WaveUploaded byvarmaprasad
- How Vedic Math Benefits Everyone - School BoardUploaded bytanja56
- Big-O Algorithm Complexity Cheat SheetUploaded byManoj Pandey
- Manual FreefemUploaded byTarak Kharrat
- fem4Uploaded bykissjack_123
- homework 25-05 - 29- 05Uploaded byapi-239483488
- 02 Fundamentals of the Analysis of Algorithm EfficiencyUploaded bytierSarge
- GATE QuestionUploaded byAyaan Mitra
- BrochureUploaded byaspiredesigns
- xcvcbcbUploaded bybelinaro8000
- newsletter march 9-13Uploaded byapi-245696657
- correct math ed assignment 3Uploaded byapi-231564434
- thanksfromdrorUploaded byapi-327991016
- curriculum conferenceUploaded byapi-265367113
- day 3 math resources bUploaded byapi-345598037
- Starting School in IDR - Parent Meeting June 2014Uploaded byMarjon Bakker
- Vinay PandeyUploaded byRavi Kumar Singh
- Study-Planner-For-Board-Examinations[1].pdfUploaded bykeerthy
- communication lettersUploaded byapi-316859396
- reviewgamesUploaded byapi-324641737
- grade 1 mathematics overviewUploaded byapi-261894978
- period 3 window 1Uploaded byapi-373598912
- all benchmarksUploaded byapi-276011962
- MENG 3705 Project and Assessment - Spring 2015Uploaded bySamuel George