• Tidak ada hasil yang ditemukan

FACULTY OF MEDICAL SCIENCES - Rama University

N/A
N/A
Protected

Academic year: 2024

Membagikan "FACULTY OF MEDICAL SCIENCES - Rama University"

Copied!
18
0
0

Teks penuh

(1)

FACULTY OF ENGINEERING & TECHNOLOGY

Lecture : 01

Mr. Nilesh

Assistant Professor

Computer Science & Engineering

(2)

 Outline

Introduction of Design and Analysis

Analysis of Algorithms

Need of Analysis

I. Methodology of Analysis II. Behavior of Algorithms

III. Asymptotic Notations (ASN)

(3)

Introduction of Design and Analysis

Consists of Finite set of Steps to solve a problem Ex: 1. X= Y+Z

2. Read(a) 3. for i 1 to n

X=Y+Z

One or more operations I. definiteness(Clear) II. Effective

May accept one or More Inputs

Must produce at least on Output

ALGORITHMS

(4)

 Life Cycle Steps

1. Problem Define

2. Requirements Specification 3. Design(Logic)

4. Express(Algo/Flowchart) 5. Validation(correctness) 6. Analysis

7. Implementation

8. Testing & Debugging

DAA

(5)

 Need of Algorithms

 Resource Comparison 1. Time

2. Space 3. Energy

4. Bond width 5. Register

 Performance Comparison : Which also is best among all.

(6)

 Methodology of Analysis

How much time taken by it X=Y+Z

It depends on- Platform

• Hardware

• Software 1. Posterior Analysis:

I. Platform Dependent II. Experimentation 2. Priori Analysis:

I. Platform Independent II. Order of Magnitude

III. Operations: +,-,*

(7)

 Need of Algorithms

 Posteriori Analysis

Advantages: Exact/ Real values of time & Space in units Disadvantage: Difficult to carry out

Non- Uniform values gives.

 Oder of Magnitude: refers of frequency (No. of times) of the function/operations Involved in the steps/ statements.

(8)

 Behavior of Algorithms

 Types of Analysis:

1. Worst case 2. Best case

3. Average Case

Consider the Example

Given --- (a1, a2, a3, a4 …an) I/P --- Inc. Order, I1

Dec. Order, I2 Random ,I3

(9)

 Behavior of Algorithms

 Worst-case: maximum number of steps taken on any instance of size n.

 Best-case: minimum number of steps taken on any instance of size n.

 Average case: average number of steps taken on any instance of size n.

(10)

 Asymptotic Notations

 We can never provide an exact number to define the time required and the space required by the algorithm.

 It is an express or standard notations of time and space, known as Asymptotic Notations.

 Mathematical Representation

 Bounds of Function 1. Upper

2. Lower 3. Tight

(11)

 Asymptotic Notations

 Time complexity of T(n) = (n2 + 3n + 4)  quadratic equation

 For large values of n, the 3n + 4 part will become insignificant compared to the n2 part.

(12)

 Types of Asymptotic Notations

We use three types of asymptotic notations to represent the growth of any algorithm, as input increases:

1.Big Theta (Θ) 2.Big Oh(O) 3.Big Omega (Ω)

 Asymptotic Notations

(13)

• Given functions f(n) and g(n), we say that f(n) is O(g(n)) if there are positive constants

c and n0 such that

f(n)  cg(n) for n n0

• Example: 2n + 10 is O(n) – 2n + 10  cn

– (c  2) n  10 – n  10/(c  2)

– Pick c = 3 and n0 = 10

1 10 100 1,000 10,000

1 10 100 1,000

n

3n 2n+10 n

 Big Oh(O)

(14)

 Big Omega (Ω) & Big- Theta

big-Omega

f(n) is (g(n)) if there is a constant c > 0

and an integer constant n0  1 such that

f(n)  c•g(n) for n  n0

big-Theta

f(n) is (g(n)) if there are constants c’ > 0 and c’’ > 0 and an integer constant n0  1 such that c’•g(n)  f(n)

 c’’•g(n) for n  n0

(15)

Big-Oh

f(n) is O(g(n)) if f(n) is asymptotically less than or equal to g(n)

big-Omega

f(n) is (g(n)) if f(n) is asymptotically greater than or equal to g(n)

big-Theta

f(n) is (g(n)) if f(n) is asymptotically equal to g(n) Small/Little Notation:

Small- Oh: Proper Upper Bond

Small-Omega: Proper Lower Bond

 Notes

(16)

 Some common asymptotic notations −

constant − Ο(1)

logarithmic − Ο(log n)

linear − Ο(n)

n log n − Ο(n log n)

quadratic − Ο(n2)

cubic − Ο(n3)

polynomial − nΟ(1)

exponential − 2Ο(n)

(17)

Q: What is time complexity of fun()?

int fun(int n) {

int count = 0;

for (int i = n; i > 0; i /= 2) for (int j = 0; j < i; j++)

count += 1;

return count;

}

Options:

A. O(n^2) B. O(nLogn) C. O(n)

D. O(nLognLogn)

 Practice

(18)

Q: What is the time complexity of fun()?

int fun(int n) {

int count = 0;

for (int i = 0; i < n; i++) for (int j = i; j > 0; j--)

count = count + 1;

return count;

}

Options:

A. Theta (n) B. Theta (n^2)

C. Theta (n*Logn)

D. Theta (nLognLogn)

 Practice

Referensi

Dokumen terkait

Section 13 of the Transfer of Property Act, 1882 provides that when for the transfer of property, an interest therein is created for the benefit of an unborn person at the date of the

Under this section, judgments neither inter parties nor in rem are relevant, if they relate to matters of public nature under inquiry.. The words ‘matters of public nature’ means

—For the purpose of filling the seats of members of the Council of States retiring on the expiration of their term of office the President shall, by one or more notifications published

Likewise, animal articles, trophy or uncured trophy, meat derived from any wild animal, ivory imported to India, article made from such ivory, vehicle vessel weapon, trap or tool that

• CO2 is important for Photosynthesis, CO2 taken by the plants by diffusion process from leaves through stomata • CO2 is returned to atmosphere during decomposition of organic

Micro irrigation requires pumps for developing the required pressure for delivering water through pipelines, regardless of whether the source of water is surface or underground.. •

Rather than getting 10000 plants per year from an initial cutting in vegetative propagation, one can obtain more than 1,000,000 plants per year from one initial explants through micro

The Charter of 1726 made Mayor' Courts at all the three administrations that is Madras, Calcutta and Bombay consequently, out of the blue, building up a uniform legal framework.. 3 The