Free Samples

COMP4600 Advanced Algorithms

.cms-body-content table{width:100%!important;} #subhidecontent{ position: relative;

overflow-x: auto;

width: 100%;}

COMP4600 Advanced Algorithms

0 Download8 Pages / 1,759 Words

Course Code: COMP4600

University: Australian National University

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: Australia

Question:

Finding the solution for n ≤ 3 takes only a constant amount of time. The divisionof the problem into 3 parts and the combination of S1, S2, S3 into the solution S each take O(n) time. In your answers, you may ignore the problem of rounding to integer. (For example, as in the pseudocode you can ignore the difference between n/3 and bn/3c or dn/3e.)

(i) Write a recurrence for the running time.

(ii) Demonstrate how to guess a solution of the recurrence by applying the recurrence repeatedly to itself.

(iii) Use induction to prove your guess is correct.

Question 2.

The following is a procedure that sorts an array A[0 · · · n−1]. procedure mysort(A, n)

for j from n−2 downto 0 do

x := A[j]

k := j + 1

while k < n and A[k] < x do
A[k−1] := A[k]
k := k + 1 endwhile
A[k−1] := x endfor end procedure
The meaning of the for statement is that j takes the values n − 2, n − 3, . . . , 1, 0 in that order.
(a) In 80 words or less describe how the procedure works. (A formal proof is not needed.)
(b) Using the Θ( ) notation, determine the worst-case running time of the procedure for sorting an array of length n.
(c) Now suppose we use the algorithm to sort arrays of distinct elements in random order, where each of the n! possible orders is equally likely. Find a lower bound for the average running time, using the ?( ) notation.
Question 3.
A row of n students are sitting directly behind each other, trying to see the screen at the front of the room. Each student can see the screen only if she is at least as tall as all the students in front of her. Let h[1], . . . , h[n] be the heights of the students, starting furthest from the screen. For example, if h[1] = 4, h[2] = 5, h[3] = 2, h[4] = 4, then students 2 and 4 can see the screen, but student 1 is blocked by student 2, and student 3 is blocked by student 4.
(a) Prove that when the following algorithm finishes, the stack contains exactly those students who can see the screen. Initialize a stack S for i from 1 to n do while S is not empty and h[i] > h[Top(s)] do Pop S endwhile Push i onto S endfor

(b) The algorithm has n “steps” corresponding to the values of i. What is the worst case time for one step? Use the Θ( ) notation and assume that Push and Pop take constant time.

(c) Give elementary reasoning why the total running time is O(n).

(d) Using the stack size as a potential function, write a careful proof of O(n) total running time using the potential method.

Question 4.

Let X be a random variable whose values are non-negative integers. Using the definition of expectation, prove that Prob(X ≥ 1) ≤ E(X).

Question 5. [0 or 10 marks] This question is compulsory for COMP8460 students. Other students can optionally answer the question and obtain up to 10 bonus marks.

One way to define a random graph is like this: Take some function p(n) which is always between 0 and 1. Take n vertices. For each pair v, w of distinct vertices, put an edge between v and w with probability p(n); otherwise no edge. Each of the decisions about whether to insert an edge are made independently of each other.

(a) What is the expected number of edges? Write both an exact answer and an approximate answer using the Θ( ) notation.

(b) What is the expected number of triangles? (A triangle is a cycle of length 3.) Write both an exact answer and an approximate answer using the Θ( ) notation.

(c) An isolated vertex is a vertex which has no edges incident to it. What is the exact expected number of isolated vertices?

(d) Given two distinct vertices v, w, a 2-path between v and w is a path of two edges v—u—w where u is a vertex different from v and w. Note that the 2-paths between v and w have no edges in common, so they are independent. Write an exact expression for the probability that a particular pair of vertices v and w have no 2-path between them. Infer an exact expression for the expectation of the number of pairs of distinct vertices with no 2-paths between them. (e) Let p(n) = n

−1/2 log n. Using your answer from part (d), and the inequality in

Answer:

1 (a) Simplify the expressions

? (n 8(log n) 9 + 4e n (log n) 3 − 7(log n) 3 )

n 8 (log n) 9 + 4e n (log n) 3 − 7(log n) 3= n 8. log n 9 + 4e n .log n 3 – 7.log n. 3

let n8 =K, 4e n=m

log K n+ m.log n 3 – 7.log n 3

? (( n+k)(log K) + 3m (log n)– 10(log n))

?(log (K n+k +n3m)/(n10) )

0(n) =1

0(log n) =log n

Taking n2 as k

Then :

(log nk +1 )/(log nk)

Θ(g(n)) + o(g(n)), where g(n) is a function that is positive for large enough n

Definition:

Let f and g be two functions f, g : N → R + . We say that

f(n) ∈ Θ(g(n))

if there exist constants c1, c2 ∈ R + and n0 ∈ N such that for every integer n ≥ n0,

c1g(n) ≤ f(n) ≤ c2g(n)

Θ(g(n)) = O(g(n)) ∩ Ω(g(n))

Replacing Θ(g(n))

Then:

O(g(n)) ∩ Ω(g(n)) + O(g(n))

(b) Find expressions for the following summations (as a function of n) using the Θ( ) notation

The time complexity is Θ()

(c) Using the Θ( ) notation, what is the running time of this code fragment as a function of n?

i := 1

sum := 0

while i ≤ n do

for j from 1 to i do

prod := 1

for k from 1 to i do

prod := prod ∗ k

endfor

sum := sum + prod

endfor

i := i ∗ 3

endwhile

Solution

At the while loop, the increment of i is not linear as it in goes from 1,3,9,…i*3.

Analysis of the increment of i :

i = 1, i<=n, i=i*3
1st execution i=1=30
2nd execution i=3 = 31
3rd execution i=9 = 32
Nth exection i= 3n-1
The algorithm stops when 3n-1 =n
Taking n-1=k
Then while loop stops when 3k=n
Time taken
K= log3n
Note that when n is 1, the estimation runs one times. This shows the lower bound of the computation as Ω(n). The for-circles are dependent of the expansion of I, which implies every increase result to i3 number of times. In this way the time unconventionality of the estimation if 0(log3n) - the upper bound. Relating the lower bound and upper bound, we can for the most part reason that the two cases fuse the 3k=n. Giving it a tight bound of ?(log3n).
(d) (i) Write a recurrence for the running time.
COMP4600 Is a recursive function that calls itself referencing to the value of n. S1, S2, S3 call the function are run equal times since the values of P1, P2, P3 is the same. Values of S1, S 2, S3 are gotten when n is less than 3. The function ends when n is less than 3.
Recurrence
funtion COMP4600(problem P of size n)
if n ≤ 3 then
return the solution --------- base case=T(o)
else
Divide P into 3 subproblems P1, P2, P3 of size n/3
S1 := COMP4600(P1) ----- 0(n)
S2 := COMP4600(P2)------ 0(n)
S3 := COMP4600(P3) ----- 0(n)
Combine S1, S2, S3 into the solution S
return S -----------------------T(n)
endif
endfunction
recursive relation = n+n+n = 3n
T(n)= ?(3n).
(ii) Demonstrate how to guess a solution of the recurrence by applying the recurrence repeatedly to it.
Since S1, S 2, S3 take the same time, while n reduces by the factors of 3. Then estimation of the solution would base on the factors of 3 in n while assuming the decimals in the result. Given the factors of 3 in n to be k, then:
Recursive relation = kn + kn + kn = 3kn
T(n)= ?(3kn).
(iii) Use induction to prove your guess is correct.
Induction: assume for some arbitrary value of n than T(n)= ?(3kn), decimals are assumed (Bubeck, 2015, Pg. 234).
T(n)=0---base case
Let n=1, 2
K= 1/3, 2/3,
K of 2, 3 =0.33, 0.66 assuming the decimals, k=o,o
Induction case
T(1)= ?(3*0*1)
T(1)=0
T(2)= ?(3*0*2)
T(2)=0
Conclusion:
Thus we conclude that T(n)= ?(3kn).
2(a) The procedure is a sorting function – Mysort, that takes two arguments A and n. In this algorithm, a nested loop is used. The different invariant holds – in the j-th times of the outer loop, there is a relative ordering of in the items of A[0] through A[j-1]. In order to insert an item in a relative position of the sort, there is a necessity of moving values to the right to make room. The first two items are put in the correct relative order, and then the third item correct to the first two in that order until the whole array of data is sorted.
(b)
(n-1)+(n-2)+….+1=
The time complexity is Θ(n2 )---Worst case scenario.
(c) Basing on distinct elements of a random order that would give equally likely n! possible orders under this sort, then the lower bound would not be any different from the time complexity (Deb, 2014, Pg. 415). Hence ?(n2 ).
(a) Prove that when the following algorithm finishes, the stack contains exactly those students who can see the screen. Initialize a stack S
for i from 1 to n do
while S is not empty and h[i] > h[Top(s)] do

Pop S

Endwhile

Push i onto S

Endfor

First, the algorithm runs

The for-loop runs n times, and for each i-th time, the while –loop runs to pop S if S is not empty and the height of the student in the h[i] position is greater than that of h[Top(s)], or the position I is pushed onto S. By the time the algorithm runs n times, only those heights that meet the while condition shall be popped. Hence, when the algorithm finishes, the stack will contain students who can see the screen only.

b)

for i from 1 to n do ————-n

while S is not empty and h[i] > h[Top(s)] do———-1

Pop S

Endwhile

Push i onto S

Endfor

T(n)=n+1

Time complexity = ?(n)

(c) Given that the while loop runs one in every i-th time the for-loop runs, it is evident that the algorithm depends on the nth times to finish. Hence, the time complexity of 0(n) as provided by Pal & Wang (2017).

(d) Prove that time complexity

Definition:

f(n)= 0(g(n))

if f(n) ≤ C.g(n) for all n≥ k ….where C and k are positive

(f(n))/(g(n)) ≤ C for all n≥ k

Taking C=4 then:………number of students in the raw

n+1 ≤ 4* g(n) for all n ≥ 1

n+1 ≤ 4* n……………….n=1

2 ≤ 4

Then f(n) = 0(g(n))

Conclusion: we have proved that time complexity of the algorithm is indeed 0(n)

Proof that Prob(X ≥ 1) ≤ E(X).

Using Markov’s inequality (Schacht, 2016, pg)

P(X ≥ a) ≤ E(X)/a

Indicator function 1 X ≥ a

Multiplying the indicator function by a constant a:

a(1 X ≥ a)

If x accessed 18 December 2021.

My Assignment Help. Advanced Algorithms [Internet]. My Assignment Help. 2021 [cited 18 December 2021]. Available from: https://myassignmenthelp.com/free-samples/comp4600-advanced-algorithms/genetic-algorithms-for-pattern-recognition.html.

×

.close{position: absolute;right: 5px;z-index: 999;opacity: 1;color: #ff8b00;}

×

Thank you for your interest

The respective sample has been mail to your register email id

×

CONGRATS!

$20 Credited

successfully in your wallet.

* $5 to be used on order value more than $50. Valid for

only 1

month.

Account created successfully!

We have sent login details on your registered email.

User:

Password:

For years, MyAssignmenthelp.com has been operating as one of the cheap assignment help providers in the USA. We are one of the best college paper writing services that keep service price minimal. We do not let the affordability of our service to hamper the standard of our work. We have separate teams of experts to provide report writing help . At MyAssigenmnthelp.com, we believe in earning credibility, so students can pay for assignments only after getting satisfied solutions. Tough assignments bother you? Trust us with your project. You will not regret paying us to write assignments for you.

Latest Management Samples

div#loaddata .card img {max-width: 100%;

}

MPM755 Building Success In Commerce

Download :

0 | Pages :

9

Course Code: MPM755

University: Deakin University

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: Australia

Answers:

Introduction

The process of developing a successful business entity requires a multidimensional analysis of several factors that relate to the internal and external environment in commerce. The areas covered in this current unit are essential in transforming the business perspective regarding the key commerce factors such as ethics, technology, culture, entrepreneurship, leadership, culture, and globalization (Nzelibe, 1996; Barza, 2…

Read

More

SNM660 Evidence Based Practice

Download :

0 | Pages :

8

Course Code: SNM660

University: The University Of Sheffield

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: United Kingdom

Answers:

Critical reflection on the objective, design, methodology and outcome of the research undertaken Assessment-I

Smoking and tobacco addiction is one of the few among the most basic general restorative issues, particularly to developed nations such as the UK. It has been represented that among all risk segments smoking is the fourth driving purpose behind infections and other several ailments like asthma, breathing and problems in the l…

Read

More

Tags:

Australia Maidstone Management Business management with marketing University of New South Wales Masters in Business Administration

BSBHRM513 Manage Workforce Planning

Download :

0 | Pages :

20

Course Code: BSBHRM513

University: Tafe NSW

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: Australia

Answer:

Task 1

1.0 Data on staff turnover and demographics

That includes the staffing information of JKL industries for the fiscal year of 2014-15, it can be said that the company is having problems related to employee turnover. For the role of Senior Manager in Sydney, the organization needs 4 managers; however, one manager is exiting. It will make one empty position which might hurt the decision making process. On the other hand, In Brisba…

Read

More

MKT2031 Issues In Small Business And Entrepreneurship

Download :

0 | Pages :

5

Course Code: MKT2031

University: University Of Northampton

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: United Kingdom

Answer:

Entrepreneurial ventures

Entrepreneurship is the capacity and willingness to develop, manage, and put in order operations of any business venture with an intention to make profits despite the risks that may be involved in such venture. Small and large businesses have a vital role to play in the overall performance of the economy. It is, therefore, necessary to consider the difference between entrepreneurial ventures, individual, and c…

Read

More

Tags:

Turkey Istanbul Management University of Employee Masters in Business Administration

MN506 System Management

Download :

0 | Pages :

7

Course Code: MN506

University: Melbourne Institute Of Technology

MyAssignmentHelp.com is not sponsored or endorsed by this college or university

Country: Australia

Answer:

Introduction

An operating system (OS) is defined as a system software that is installed in the systems for the management of the hardware along with the other software resources. Every computer system and mobile device requires an operating system for functioning and execution of operations. There is a great use of mobile devices such as tablets and Smartphones that has increased. One of the widely used and implemented operating syste…

Read

More

Tags:

Australia Cheltenham Computer Science Litigation and Dispute Management University of New South Wales Information Technology

Next