41 views

Uploaded by Rohit Chaudhary

- Algorithms
- Algorithms Notes for Professionals
- Substitution Examples
- chap1-111206
- Problem Set 1 GettingStarted
- Asymptotic Notations in Algorithms
- CS8451-QB.pdf
- chapter7
- 4. Thinking Strategically About Thinking Strategically
- 071003_lecture
- nongatebook (1)
- 1.2.1_Complexity Oct 2013
- lects1-10
- samrup
- Lec1_analyzingAlgorithmandProblems
- 1993-15-Makela Reparación Archivos STL
- The Complexity of Timetable Construction Problems
- Josephus Problem
- P-NP-NP-Complete.doc
- 1-s2.0-S0304397507001272-main

You are on page 1of 37

the input and output

6

M

a nput

© A sequence of numbers <a1, a2, ǥ,an>

a Output

© A permutation (reordering) of the input sequence

such that aǯ1 Ôaǯ2 Ôǥ Ôaǯn

6 66

G

a A correct algorithm

© Always produces the correct output for any input

a For example:

© nput <31,41,59,26,41,58>

© >>>>>A correct algorithm<<<<<

© <26,31,41,41,58,59>

6 66

c

a Describe the instruction in words

© What kind of computer programming languages?

r Doesnǯt matter

© What kind of human spoken languages?

r Mhe language you like, even Chinese, Martian

Language

6 66

Î

a delection dort

selectiondort( numbers[], array_size)

{

i, j, min;

(i = 0; i < array_size-1; i++)

{

min = i;

(j = i+1; j < array_size; j++)

{

(numbers[j] < numbers[min])

min = j;

}

if(min!=i) swap(numbers[x],numbers[i]);

}

}

6 66

Î

a Mergedort

© deparate the list into halves

© dort the two halves recursively

© Merge the two sorted halves into one sorted list

6 66

c

a etter means

© Mime

© dpace

a Generally focusing on the worst-case number

of comparisons required to solve the

problem.

6 66

M

a delection dort

© n-1, n-2, n-3, ǥ., 1

© O(c1n2)

a Merge dort

© M(n)=M(n/2) + M(n/2) + cn

© ǥ

© M(n)=O(c2nlog2n)

6 66

M

a And dpace?

6 66

M

a Mwo machine

© Machine A: 109 per second instructions

© Machine : 106 per seconds instructions

a dupposed c1=2, c2=50

a We want to sort 102 integers

© Which one runs faster?

a We want to sort 106 integers

© Which one runs faster?

6 66 6

G

© dentify 100,000 genes

© Determine 3 billion chemical based pairs

© Genes search between different human

6 66 66

G

© P route method.

© dearch Engine

© Compress the data

© How to store the password (RdA)

© Network decurity

© Lots of problems

6 66 6

G

a Manufacturing

© Resources price

© Human power price

© Mransportation price

© Market

© Mhe place to set the

r Factories

r Warehouse

r dtores

6 66 6

G

a Hardware

a GU

a Object-Oriented dystem

a WAN, LAN

a ǥ

6 66 6

M

a Program P2 solves the same problem in 2p

seconds.

a A: Program P1 runs faster for p > 20.

6 66 6

a We need notation to capture the concept of

ǲrate of growthǳ when we measure the time

and space efficiency of algorithms

6 66 6

a Edmund Landau

© 1877~1938

© nventor of the asymptotic notation

a Donald E. Knuth

© 1938 ~

© Muring Award, 1974.

© Father of the analysis of algorithms

© Popularizing the asymptotic notation

6 66 6

a §

a

a

6 66 6

V

a Let n be the number of input integers

© Program 1 takes time O(n)

© t takes time O(n) for program 1 to solve the

problem

© Mhe time required by program 2 is O(2n)

a O(n) reads?

© ig-Oh of n

© Order n

6 66 6

a dentence

Program p2 takes time O(n) to solve the problem.

a Means

© Mhe time needed by p2 is a function f(n) with

f(n)=O(n)

6 66

a dentence

© Mhe comparison-based sort methods can not be

solved in O(n) time.

a Means

© Mhe comparison-based sort problems can not be

solved in h(n) time, for any function h(n) with

h(n)=O(n)

6 66 6

×

a ntuitive meaning

© f(n) does not grow faster then g(n)

a Comments

© f(n)=O( g(n) ) roughly means f(n) Ô g(n) in terms of

rate of growth

© = is not the meaning of equation. tǯs more like

© We do not write O(g(n))=f(n)

6 66

u

!
×

×

f(n)=O(g(n))

f there exists positive constants p and such

that the inequality pÔp

holds for each integer p½ p

6 66

c

there exists a positive constant such that

the value of pis upper-bounded by p

for all sufficiently large positive integers p.

6 66

a n=O(n)?

a 999n=O(n)?

a 5n2=O(n3-n2)?

a n2=O(n)?

6 66

a n Ô 1n , for n 1

6 66

èèè

a 999n Ô 999n , for n 1

6 66

Ñ "

#

a 5n2Ô5(n3-n2)

a 5n2 Ô 5n3-5n2

a 10n2Ô 5n3

a 2Ô n

6 66

© nstinctive feeling: NO

a How to proof?

© Contradiction Method

6 66

constants and p such that

a p Ôp

a holds for any integer p with p½ p . p is an

arbitrary integer strictly larger than

max(p ,).

a For instance, let p

p

a n2>cn (n>c), contradiction.

6 66

other asymptotic notations.

© f(n)=O(g(n)) f(n) Ô g(n) in rate of growth

© f(n)=(g(n)) f(n) ½ g(n) in rate of growth

© f(n)=±(g(n)) f(n) È g(n) in rate of growth

© f(n)=o(g(n)) f(n) ß g(n) in rate of growth

© f(n)= ɘ(g(n)) f(n) g(n) in rate of growth

6 66 6

a D

©

!"#!!""

$%&

&' &

!"(&!"

)( *

©

&!" + ,
-'

!"*

©

!"#!!""-

%)!" '-

&

&&

,

,&

!"#!!""
*

.6/0&& 6 66

M

a D

/

©

!"#±!!""

$%&

&6)& ' &&6!"1

!"1&!"

)( *

a 2,
-''
-'

!"

a
&

-3-4'*

.6/0&& 6 66

G

M

Algorithm in terms of worst-case time

complexity if there exists a positive function

f(n) such that

© Algorithm A runs in time O(f(n)) and

© Algorithm runs in time (f(n)) in the worst case

6 66

G

M

in terms of worst-case time complexity if

there exists a positive function f(n) such that

© Algorithm A runs in time O(f(n)) and

© Algorithm runs in time ɘ (f(n)) in the worst case

OR

Algorithm A runs in time o(f(n)) and

© Algorithm runs in time (f(n)) in the worst case

6 66

M

complexity of a algorithm is O(f(n)). We say

that the analysis is tight if the algorithm runs

in (f(n)) in the worst case.

a n others words, if the time complexity of the

algorithm is O(f(n)) and the analysis is tight,

then the time complexity of the algorithm is

(f(n))

6 66

M

algorithm for a problem P in terms of worst-

case time complexity if

© Algorithm A runs in time O(f(n)) and

© Any algorithm that solves the problem P requires

time (f(n)) in the worst case.

6 66

- AlgorithmsUploaded byravg10
- Algorithms Notes for ProfessionalsUploaded byconrado
- Substitution ExamplesUploaded bybhadresh74
- chap1-111206Uploaded bykamarajvlsi
- Problem Set 1 GettingStartedUploaded byPhan.Huy.Cong
- Asymptotic Notations in AlgorithmsUploaded byNaveed Tawargeri
- CS8451-QB.pdfUploaded byThilaga Mylsamy
- chapter7Uploaded byVikas Bhardwaj
- 4. Thinking Strategically About Thinking StrategicallyUploaded byamiraslam2k
- 071003_lectureUploaded bySangeetha Sangu BC
- nongatebook (1)Uploaded byLakshay Kakkar
- 1.2.1_Complexity Oct 2013Uploaded byvarunsingh214761
- lects1-10Uploaded byRokibul Alam
- samrupUploaded bysomrup
- Lec1_analyzingAlgorithmandProblemsUploaded byAlan Chan
- 1993-15-Makela Reparación Archivos STLUploaded byPipeGo
- The Complexity of Timetable Construction ProblemsUploaded byzxmn
- Josephus ProblemUploaded byManikandan Natarajan
- P-NP-NP-Complete.docUploaded byakilrsdi
- 1-s2.0-S0304397507001272-mainUploaded byGhiya-chan Murakami
- cadUploaded byshekhartit
- approx-faclocUploaded bypostscript
- Primitive Polynomial GenerationUploaded bysheebascribd
- Study of Sorting Algorithm to Optimize Search ResultsUploaded byAnonymous vQrJlEN
- PrinciplesofDataStructuresUsingCandC_WeLearnFreeUploaded byAftab Khan
- 23 Fl 24 Np CompleteUploaded byAnirban Baral
- A New Succinct Representation of RMQUploaded bySantiago Castro
- Two greedy algorithms for a binary quadratically constrained linear program in survey data editingUploaded bypaundpro
- IChemE_TCE_Uncovering the UnknownUploaded bysl1828

- PERFORMANCE MANAGEMENT SYSTEMUploaded byRohit Chaudhary
- 5Uploaded byRohit Chaudhary
- 24Uploaded byRohit Chaudhary
- Pf Calculation SheetUploaded byRohit Chaudhary
- Behavioral Event Interview TechniquesUploaded byRohit Chaudhary
- Training & developmentUploaded byRohit Chaudhary
- Human Resource ManagementUploaded byRohit Chaudhary
- PF Interest CalcUploaded byRohit Chaudhary
- RecruitmentUploaded byRohit Chaudhary
- 22Uploaded byRohit Chaudhary
- Recruritment & selectionUploaded byRohit Chaudhary
- HUMAN RESOURCE MANAGEMENTUploaded byRohit Chaudhary
- HUMAN RESOURCE PLANNINGUploaded byRohit Chaudhary
- Fake PhdUploaded byRohit Chaudhary
- Payroll - Celestial Labs LimitedUploaded bylegendleosiva
- Notes on Computer Networks Unit 2Uploaded byRohit Chaudhary
- Notes on Computer Networks Unit1Uploaded byRohit Chaudhary
- Calculation PFUploaded byRohit Chaudhary
- An Hr Manager Can Become a CeoUploaded byRohit Chaudhary
- CTC StructureUploaded byRohit Chaudhary
- Labour Laws New NOTESUploaded byRohit Chaudhary
- SortingUploaded byRohit Chaudhary
- Rohit Dissertation ReportUploaded byRohit Chaudhary
- Notes on Computer Networks Unit5Uploaded byRohit Chaudhary
- NBFC NEWUploaded byRohit Chaudhary
- lec_03Uploaded byRohit Chaudhary
- t13MergesortUploaded byRohit Chaudhary
- Notes on Computer Networks Unit 3Uploaded byRohit Chaudhary
- Quick SortUploaded bySurya Nair
- Notes on Computer Networks Unit4Uploaded byRohit Chaudhary

- Algorithms - Computer Science NotesUploaded byJose Salvatierra
- Algorithm-Analysis.pptUploaded bymeryamreza
- cs240Uploaded byBen Zhang
- Matrix BookUploaded byBrandon Mcguire
- Data StructuresUploaded bySwati Sukhija
- Complexity of an Algorithm lect-2.ppsUploaded byTanmay Baranwal
- Midterm1 SolutionUploaded byMADDY
- Algorithm for integer MultiplicationUploaded bypi194043
- AlgorithmsUploaded byohyeah08
- Draft Asymptotic Analysis ReportUploaded byAlessio Failla
- Mid Semester Marking Scheme.docxUploaded byengler808
- AdaUploaded byrao001
- DST FingerprintUploaded byAli DM
- UntitledUploaded byvenureddy129
- M.N. Huxley-The Distribution of Prime Numbers_ Large Sieves and Zero-Density Theorems (Oxford Mathematical Monographs)-Oxford University Press (1972)Uploaded byDaniél Cárdenas
- Flame Acceleration in the Early Stages of Burning in Tubes(2007)Uploaded bySinan Demir
- Interpolation SortUploaded byVijyan Mahajan
- D35 Data Structure2012Uploaded byPonmalar Sivaraj
- Ae Chapter2 MathUploaded byjruan
- Comparative Analysis between Split and HierarchyMap Treemap Algorithms for Visualizing Hierarchical DataUploaded byijcsis
- Big-O notationUploaded byJC Asido
- Classes.soe.Ucsc.edu Cmps102 Fall01 Solutions 3Uploaded byAshok Chakravarthy
- 1-2Uploaded byMuhammad Umer Arshid
- 202.pdfUploaded byAbhiman Reddy
- MA4263Uploaded byecd4282003
- ppl1Uploaded bysathish_arukonda9462
- nongatebook (1)Uploaded byLakshay Kakkar
- Data Unit4Uploaded byPrasobh Shamohan
- Unit IUploaded bySamay
- Mehlhorn K., Sanders P. Concise algorithmics, the basic toolbox 124ñ. .pdfUploaded bydeisecairo