0% found this document useful (0 votes)
16 views21 pages

Numerical Computation - Lec - 4 - Part 1 PDF

The document outlines the content of Lecture 4 on Numerical Computation, focusing on the role of algorithms, their design, analysis, and growth of functions. It discusses the analysis of algorithms in terms of running time, including worst-case, best-case, and average-case scenarios, as well as methods for comparing algorithms. Additionally, it introduces asymptotic notation and recurrences, along with methods for solving them.

Uploaded by

Jumayna Ghida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views21 pages

Numerical Computation - Lec - 4 - Part 1 PDF

The document outlines the content of Lecture 4 on Numerical Computation, focusing on the role of algorithms, their design, analysis, and growth of functions. It discusses the analysis of algorithms in terms of running time, including worst-case, best-case, and average-case scenarios, as well as methods for comparing algorithms. Additionally, it introduces asymptotic notation and recurrences, along with methods for solving them.

Uploaded by

Jumayna Ghida
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Numerical

Computation
Lecture 4 (Part1)

Dr. Metwally Rashad


2023
Course Contents

Part 1 Part 2 Part 3


 Foundations  More Algorithms
- The Role of Algorithms in - Sorting Algorithms
Computing - Graph Algorithms
- Design and Analysis algorithms - Dynamic Programming
- Growth of Functions - Greedy Algorithms
 Numerical Methods
- Solving Nonlinear
Equations
- Solving Linear Systems
- Interpolation,
Polynomial Approximation
1/18
Lec.4
- The Role of Algorithms
in Computing
- Design and Analysis algorithms
- Growth of Functions (Part 1)
Analysis of Algorithms
 An algorithm is a finite set of precise instructions for
performing a computation or for solving a problem

 What is the goal of analysis of algorithms?


 To compare algorithms mainly in terms of running time but also in terms of
other factors (e.g., memory requirements, programmer's effort etc.)

 What do we mean by running time analysis?


 Determine how running time increases as the size of the problem increases.

3/18
Types of Analysis
 Worst Case
 Provides an upper bound on running time
 An absolute guarantee that the algorithm would not run longer, no matter what the inputs are
 best Case
 Provides a lower bound on running time
 Input is the one for which the algorithm runs the fastest

 Average case
 Provides a prediction about the running time
 Assumes that the input is random

Lower Bound  Running Time  Upper Bound 4/18


How do we Compare Algorithms?

 We need to define a number of objective measures.


(1) Compare execution times?
Not good: times are specific to a particular computer!!

(2) Count the number of statements executed?


Not good: number of statements vary with the programming
language as well as the style of the individual
programmer.
5/18
How do we Compare Algorithms? (cont.)

 Ideal Solution

 Associate a "cost" with each statement.


 Find the "total cost“ by multiplying the cost with the total number of
times each statement is executed.
6/18
Asymptotic Notation

7/18
Asymptotic Notation(cont.)

8/18
Asymptotic Notation(cont.)

9/18
Asymptotic Notation(cont.)

10/18
Asymptotic Notation(cont.)

11/18
Asymptotic Notation(cont.)

12/18
Asymptotic Notation(cont.)

(Ex. 1)

(Ex. 2)

13/18
Properties of Asymptotic Notation
 Transitivity:

 Reflexivity:

 Symmetry:

 Transpose symmetry:
14/18
Logarithms

logk n  (log n ) k
Binary logarithm lg n  log2 n log log n  log(logn )
Natural logarithm ln n  loge n log x y  y log x
log xy  log x  log y
x
log  log x  log y
y
loga x  loga b logb x
a logb x  x logb a 15/18
Recurrences
 Recurrence: an equation that describes a function in terms of its
value on smaller

 c n 1


 The expression T ( n)  
2T  n   cn n 1

 2
is a recurrence 16/18
Recurrences Examples

 0 n0  0 n0
s ( n)   s ( n)  
c  s (n  1) n  0 n  s (n  1) n  0

 c n 1  c n 1
 
T ( n)   T ( n)  
2T    c n  1
 n  n
aT    cn n  1
  2   b
17/18
Solving Recurrences
 Three methods for solving recurrences
 Substitution Method
 Recursion-tree Method
 Master Method

18/18
Lec.5: Growth of
Functions (Part 2)
Thank
you!

You might also like