Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Principles of Algorithm Analysis, Slides of Algorithms and Programming

Shun faster algorithms to avoid complexity in program. • Instead, wait for simple N2 algorithms, when N log N alternatives exist of modest complexity ...

Typology: Slides

2022/2023

Uploaded on 05/11/2023

dewan
dewan 🇺🇸

4.6

(17)

254 documents

1 / 41

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Principles of Algorithm
Analysis
Biostatistics 615
Lecture 3
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29

Partial preview of the text

Download Principles of Algorithm Analysis and more Slides Algorithms and Programming in PDF only on Docsity!

Principles of Algorithm

Analysis

Biostatistics 615

Lecture 3

Problem Set… z

Questions?

z

FAQ:

How to compile C code?

10 minute introduction for the adventurous…

GCC z

GNU C Compiler

Available on most UNIX systems

Also on newer Macintosh computers

z

For Windows, download from

www.mingw.org

www.cygwin.com

Running GCC z

Command line application z Basic usage is: gcc –o program_name source.c

Use extension “.c” or “.cpp” for source code z Reads in source(s), creates executableprogram

Good editors for C programs… z

Commercial compilers provide veryfancy editors

z

A good free alternative is

nedit

On Windows, available when you installcygwin.

Today z

Strategies for comparing algorithms

z

Common relationships betweenalgorithm complexity and input data

z

Compare two simple search algorithms

Specific Questions z

Compare two algorithms for one task z Predict performance in a new environment

If we had a computer that was 10x faster and couldhandle 10x more data, how would approach perform? z Set values of algorithm parameters

Two Common Mistakes z

Ignore performance of algorithm

Shun faster algorithms to avoid complexity in program

Instead, wait for simple

N

2 algorithms, when N log N alternatives exist of modest complexity available z Too much weight on performance of algorithm

Improving a very fast program is not worth it

Spending too much time tinkering with code is rarelygood use of time

Choices of Input Data z

Actual data

Measures performance in use

z

Random data

Generic approach, may not be representative

z

Perverse data

Attempt worst case analysis

Limitations of EmpiricalAnalysis z

Quality of implementation

Is our favored implementation coded morecarefully than another?

z

Extraneous factors

Compiler

Machine

Computer system

Theoretical Analysis z

Predict performance of algorithm basedon theoretical properties

z

“Independent” of actual implementation

z

Several constructs occur frequently inalgorithm analysis

Limitations of TheoreticalAnalysis z

Efficiency can depend on compiler

z

Efficiency may fluctuate with input data

z

Some algorithms are not well understood

Two typical analyses z

Average-case for random input

z

Worst-case

z

Are these representative of real worldproblems?

Check with empirical predictions…

The Primary Parameter

N

z Examples

Degree of polynomial

Number of characters in a string

Size of file to be sorted

Number of input data items

Some other abstract measure of problem size z With multiple parameters, we can often holdone of them constant