 # CP5602 Advanced Algorithm Analysis

## Question:

Let nI denote how many internal nodes a tree has, and nE the number of external nodes.

It is shown that if T has exactly three children, then the nE value of nI + 1

Consider that we have two ordered search lists S and S with n elements each. S and S are implemented using arrays.

Define an O(lg2n-time algorithm to find the Kth smallest key in the union between keys S and T (assuming that there are not duplicates).

Merge sort takes in(n lg. n) worst-case times and insertion sorts takes in (n2) worst-case times. However, the constant factors of insertion make it more efficient for small sub problems. The sub lists are then sorted using insert sort, and then merged with the standard merging method, where k represents a value.

i) Shows that each of the n/k sub-lists, each with length k, can easily be sorted with insertion type in(nk), worst case time.

iii. Show that sub-lists can merge in worst case time.

iii. Given the fact that the modified algorithm runs in (nk+n/k) worst-case, what is the largest asymptotiction(value) of k as an expression of n? The modified algorithm has a similar asymptotic running speed to the standard merge sort.

: When nI equals 1, then nE is 2nI+ 1 = 2+1=5.

When nI=2, then nE is 2nI+1 = 2+1=5.

Let’s suppose that the equation “nE” is correct for k? k. This is because for any nI= k’, nE= 2nI+1 = 4.

Let’s look at k= nI.

This means that 2(k + 1) + 1 (+ (3 – 1) equals nE.

The number of external nodes equals the number which are internal for a tree with k–1 internal nodes plus 3 (we created an internal new node that must have 3 children).

Hence, nE is 2k – 2+ 3 = 0+1.

Three externals and a root = 3=2*1+1. Assume that true n trees have the following: ne=2ni +

An extension of a tree can be achieved by adding nodes.

This would make one of the old externals become internal.

To find the smallest key the algorithm uses divide-and-conquer.

When divide-and conquer is applied, both the sorted arrays SS or TT will be different.

Len(T),len(T), or len (S)len?S) are used to indicate the length of either TT (or,SS) by indicating the length.

This is the basic idea. We compare sm+tmsm+tm to kk and S[sm]S[sm] to T[tm] in order determine which half (T or S), can be discarded and which sub-problem can still be solved.

The left-larger half of array S can also be discarded. This is the range from S(sm), up to its ends.

Recursively, the kth can be found using the left-most smaller part of S and the Smallest elements of T.T. and S are then exchanged in the case of 1.1 symmetric.

Second scenario: Case 1.2. S[sm]T[tm] greater than S[sm]T[tm]; and S[sm]T[tm] greater than T[tm].

case 2 (sm+tm

Time complexity Half an array’s elements are discarded after each iteration.

The time complexity of an array is equal to O(lg (len(S),) +lg (len(T ))),), which is O for the input arrays of T and S of n size a). Sorting sub lists: When entering values of size K, insert sort is done on Th(k2).

The running time can be found in the equation (ak2+bk+c).

Running time of the form. It is important to sort sub lists with n/k form.

T(k)=Th (nk).

b) Merging the sublists.

There are n elements. We then divide the sublists into k lists, each one into n/k sorted and sorted sublists.

Two sub lists are taken simultaneously and we merge them into one list, which is sorted.

This gives us log(n/k),log. Each step is compared, so the entire process runs at Th (nlg(n/k).

C) The largest value in K when a set or rules is modified so that they have the same asymptotic time running as the one used for ordinary com Solutions.

So, Th(nlgn must be equivalent to Th(nk+nlg(1)) =Th(nk+nlgn–nlgk). In order to satisfy this state, k shouldn’t grow asymptotically quicker than lg.n. This is because if k grows faster than lg.n, the set rules will run at a slower asymptotic rate than Th(nlgn).

Consider the state Th(lgn) =k. We must also consider whether or not requirements apply to k.

Let’s suppose that k = Th (lg.n) Th+nlg.n/k), =Th (nk+nlg.n.lgk), =Th (5n lg.n.lgn.n.n.lgn.n.) =Th (2n.lg.n.n.lgn.n.) +Th (2n.lg.n.lgn.) =Th (2n.lg.n.lgn.)). In b is larger than one, the functions f(n.) is an asymptotically helpful role.

We have three possible scenarios.

A function f(1) = Th (nlogba a logkn n) with 1 k>= 0, then T(n)= Th (nlogba a logk+1,n).

(n logba+e), and function f (n) satisfying the uniformity condition. Therefore, T (n/2) = Th(f(n).

The uniformity state is that:af[n/b] = cf[n] for a constant c1 and any function f[n]=log 2i i=log 3]+nlg3T(3/2)-1]+nlg3T(3/2)-1]+nlg3T(n/2)=n/2[nlg(3)]+nlg3T(3/2)-1]+nlg3T(n/2)=1/2nlg3 HTML0 lg3T(2) =3T (?2/2?) =3T3T(1) =3T(2) =3T2/2T(?2/2?)

+2=3T(1) +2=5=c(2) lg 3

+nT (n)=3T (1) +2=5= c (2) LG 3 This holds for c >=2 Substitution T?n=3T(??n/2?)

The algorithm below can be used to verify if a universal source exists.

All calculations start at a11.

We take one steep right if the current aij entry is equal to zero, then j=j+1. If aij equals 1, then we take one step down.

We will end at the akn entry of the utmost chordon or akn on the last pier if all of these are done (n is equal or less to /V/; 1 is equal or lesser than k, and k is equivalent or less that /v/).

Begin by checking vertex K if the definition is fulfilled. If so, it means that we have found the universal sink. Otherwise, it is not.

The total running duration is given by O(V).

Since we make a consistent pace down or right, O(V) can be used to determine if an edge is a universal source.

This algorithm will return no vertex if there isn’t a universal sink.

If there is no universal sink, then the path starting from a11 will be the one that meets the uth row or uth column at any entry.

Once it is on track, it will not be able to get off it and will stop at the right entry.

Motwani R., Raghavan P. (2010).

Randomized algorithms (pp.

Chapman & Hall/CRC.

Comparison of two approaches to verify connectivity between nodes within a power network: matrix-based and trees-based.

In Multi-Topic Conference 2014 IEEE 17th International (pp.

Get 20% off your first purchase

X
Hi