Attribution Non-Commercial (BY-NC)

377 views

Attribution Non-Commercial (BY-NC)

- Recursion Trees and Master Method
- Course Material 1
- BigO
- Growth
- Fast Detour
- Image-Based Multi-Sensor Data Representation and Fusion Via 2D Non-Linear Convolution
- 02-analy
- Time complexity
- Astar
- Attempting to reverse the irreversible in quantum physics
- Combination of beliefs on hybrid DSm models
- Mergesort Analysis
- 10.1.1.54.687
- Introduction to Computation and Programming Using Python%2C Revised - Guttag%2C John v..131
- Transportation Method of LP
- MIT6_046JS15_quiz1.pdf
- Riesco-Verdejo-par-skel-tr
- Lecture k Sorting
- Data Dependency
- New Matlab Simple Program

You are on page 1of 3

Output: sorted array (Increasing values)

Recursively sorts two halves of the array, then merges the two halves into sorted

full-length array.

How to merge: Both halves sorted, so take smallest element in either array

(global min) and add to final array. Continue until both arrays are empty.

if A(i) < B(j) (1 op)

C(k) = A(i) i++ (2 ops)

Else

C(k) = B(i) j++ (also 2 ops)

total 4m+2

<6m

Claim: merge sort requires <= 6nlog2(n) + 6n ops to sort n>=1 numbers

Recall: log2(n) = # of times you divide n by 2 until you get down to 1 (grows

much less quickly than n)

Proof of claim:

Assume n=power of 2 for simplicity

Level 1: 2 arrays n/2

level 2: 4 n/4

level log2(n): n arrays of 1 element

Think of "horizontal slice" of tree and all work done at that leve

Total # ops at level j (not including actually calling the next recursive call): <=

2^j(6(n/(2^j))) -> 6n per level

= 6nlog2(n) + 6n

Comments/Takeaways:

1) Used worst-case analysis so that runtime bound holds for every array you

might encounter. Could test on benchmarks or “practical” inputs

a. Why? Difficult to define real data

b. Easier to analyze

c. Focus is to design algorithms that always do well

regardless of scenario

2) Won’t pay much attention to constants or lower order terms

a. Reasons: way easier to ignore.

b. Lose very little predictive power by ignoring constants

c. Really only interested in big problems (large n)

3) Fast Algorithm: In worst case runtime, runtime grows slowly with

input n

4) Usually want as close to linear (O(n)) time as possible (binary

search actually log2(n) time, faster than O(n)

Asymptotic Notation

Usually, T(n) is the worst-case RT on inputs of size n

A: Eventually (for large input size) , T(n) is bounded above by some

constant multiple of f(n)

T(n) = O(f(n)) if and only if there exist constants C, n0 > 0 such that

T(n) <= C*f(n) for every n > n0

Ex # 1: if

T(n) = akn^k + … + a1n + a0

Then T(n) = O(n^k)

Proof choose n0 = 1

C= abs(ak) + abs(a(k-1)) + … + abs(a1) + abs (a0)

=C*n^k QED

Ex #2: non-example

n^k is not O(n^(k-1))

Proof by contradiction:

Suppose n^k = O(n^(k-1))

There exist constants C and n0 such that:

n^k <= C*n^(k-1) for all n > n0

wrong! Cancel off n^k-1, we get n<=C for all n > n0

We can choose arbitrarily large n so this is false.

such that T(n) >= C*f(n) for all n >= n0

Basically, where do these two functions cross (n0) such that T(n) is

always greater than C*f(n)

1) T(n) = O(f(n))

AND

2) T(n) = Omega(f(n))

- Recursion Trees and Master MethodUploaded byHarsh Vardhan Jha
- Course Material 1Uploaded byashok_bbsr
- BigOUploaded byTôm Sú
- GrowthUploaded byjitensoft
- Fast DetourUploaded bymadan321
- Image-Based Multi-Sensor Data Representation and Fusion Via 2D Non-Linear ConvolutionUploaded byAI Coordinator - CSC Journals
- 02-analyUploaded byLinh Đỗ
- Time complexityUploaded byAshly
- AstarUploaded byRadha Raman
- Attempting to reverse the irreversible in quantum physicsUploaded byMark M. Wilde
- Combination of beliefs on hybrid DSm modelsUploaded byAnonymous 0U9j6BLllB
- Mergesort AnalysisUploaded bychhavish
- 10.1.1.54.687Uploaded bymanuelq9
- Introduction to Computation and Programming Using Python%2C Revised - Guttag%2C John v..131Uploaded byZhichaoWang
- Transportation Method of LPUploaded byAbhijit Singh
- MIT6_046JS15_quiz1.pdfUploaded byajgemini
- Riesco-Verdejo-par-skel-trUploaded bynaabarca
- Lecture k SortingUploaded bySahil Arora
- Data DependencyUploaded bySagar Viradiya
- New Matlab Simple ProgramUploaded bysekarjoshua
- Ch6Uploaded byapi-3815042
- FISICA 1 (1).xlsxUploaded byDiana Guisseth Bolaños Mahecha
- Sorting and SearchingUploaded byDavi Teodoro
- LogoUploaded byIvan Emiliano
- Check Material Has ExplodedUploaded byJose Grill
- 1Uploaded byphaneendra
- EXPLAIN DemystifiedUploaded byRoxana Sarbu
- FftUploaded byAnonymous sDiOXHwPPj
- Mp Lab Index Batch-2Uploaded bySrinivas Kadiyala
- Sparse MatricesUploaded bybogdann_damian

- Chapter-3-Delay-Calculation.pdfUploaded bychaitanyh
- NotesUploaded byazfarhussain8776
- Amortized Analysis Aggregate AnalysisUploaded byDeepak Mishra
- Analyzing the Effect of Gain Time on Soft-Task Scheduling Policies in Real-Time SystemsUploaded byxpeprishey
- Evaluate AlgorithmsUploaded byNurul Akmar Emran
- Analyzing AlgorithmsUploaded bySumit Narang
- adaNotes-1Uploaded bypankajghorela
- 23. Computer Science-ISCUploaded byProtyay Chakraborty
- Mobile Networks and ApplicationsUploaded byrabraj
- Boundary Value AnalysisUploaded byapi-3809615
- 6 Algorithms NCITUploaded bySukhachandra Thakur Bhumihaar
- HN DAA 15CS43 LectureNotes 1Uploaded byharivinodn
- Skip ListsUploaded bySunil Thakur
- Big O MIT.pdfUploaded byJoan
- AB20-3Uploaded byBudi Sulaiman
- 2-solutions-clrs-06-07-08Uploaded byazertytyty000
- R Asymptotic Analysis11Uploaded byskylarks
- Data Unit4Uploaded byPrasobh Shamohan
- naveenUploaded byMohit Shivay
- 33_BD_Data Structures and Algorithms - Narasimha KarumanchiUploaded byTritonCPC
- First Course in Algorithms Through PuzzlesUploaded byjorgecarranza
- dsa.pdfUploaded byAnonymous DFpzhrR
- 11Uploaded bySofia
- presentation planning sheet and handoutsUploaded byapi-308919474
- 1.0 1.1 1.2 1.3Uploaded bysatwik_thakkar
- dynamic storage allocationsUploaded bybharathayyawar
- Java Data Structures HilfingerUploaded by789by13
- Parallel Computing NotesUploaded byluvlastcall
- lectur-120121051527-phpapp01Uploaded byshemsedin shukre
- amortized.pdfUploaded bySubhajit Bhattacharyya