Your SlideShare is downloading. ×
0
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
#1 designandanalysis of algo
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

#1 designandanalysis of algo

1,776

Published on

CS202 Design and Analysis of Algorithm

CS202 Design and Analysis of Algorithm

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,776
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
68
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Design And Analysis of Algorithms
    Topic #1: Algorithm Basics
    Prepared by: BrijidaCharizma A. Navarro
  • 2. Introduction
    As future computer scientists, you will usually more concerned with writing complex program algorithm.
  • 3. Algorithms
    Step by step method of solving some problems
    Solution that can be executed by a computer
    Derived from the name of the nith-century Persian mathematician al-Khowarizmi.
  • 4. Algorithm
    A complete, step-by-step procedure for solving a specific problem.
  • 5. Pakiisipnga…..
    Does the computer understand an algorithm?
  • 6. Properties of Algorithms
    Input
    Output
    Precision
  • 7. Properties of Algorithms
    Determinism
    Finiteness
    Correctness
    Generality
  • 8. Example
    Make an algorithm that finds the maximum of three numbers a, b and c.
  • 9. Algorithm: Finding the maximum in a list of 3 numbers
    a = 1, b = 5,
    c = 3
    x = a
    If b > x then x = b
    If c > x, then x=c.
  • 10. Two Main Tasks in the Study of Algorithms
    Algorithm Design
    Analysis of Algorithms
  • 11. Algorithm Design
    To solve problems
    An art more than a science
  • 12. Analysis of Algorithms
    Will provide insights into designing new algorithms
  • 13. in analysis of algorithms, we ask ourselves the following questions:
    Correctness.Given an algorithm for a problem, does it solve the problem?
    Termination. Does the algorithm always stop after a finite number of steps?
    Time Analysis. How many instructions does the algorithm execute?
    Space Analysis. How much memory does the algorithm need to execute?
  • 14. Exercise
    Write an algorithm that finds the smallest element among a, b and c
  • 15. Solution
    x = a
    If b < x, then x = b.
    If c < x, then x = c.
  • 16. 2. Exercise
    Which properties of an algorithm – input, output, precision, determinism, finiteness, correctness, generality – if any, are lacking in the following. Explain. The input is a set of S of integers and an integer m. The output is all subsets of S that sum to m.
  • 17. Here’s the algorithm:
    List all subsets of S and their sums.
    Proceed through the subsets listed in step 1 and output each whose sum is m.
  • 18. Answer:
    If the set S is an infinite set, the algorithm will not terminate, so it lacks finiteness and output properties.
    Line 1 is not precisely stated since how to list the subsets of S and their sums is not specified; thus the algorithm lacks the precision property.
    The order of the subsets listed in line 1 depends on the method used to generate them, so the algorithm lacks the determinism property.
    Since line 2 depends on the order of the subsets generated in line 1, the determinism property is lacking here as well.
  • 19. Pseudocode for Algorithms
    Made of ordinary language
    Precision, structure and universality
    Closely resembles the actual code of computer languages such as C++ and Java
    Any version of pseudocode is acceptable as long as the instructions are unambiguous.
  • 20. Algorithm Structure
    Algorithm: Finding the Maximum of Three Numbers.
    This algorithm finds the largest of the numbers a, b, and c
    Input Parameters: a, b, c
    Output Parameter: x
    max(a,b,c){
    x = a
    if (b > x) // b is larger than x, update x
    x = b
    if (c > x) // c is larger than x, update x
    x = c
    }
  • 21. Title
    Brief description of the algorithm
    The input and output parameters
    Function containing the instructions of the algorithm
  • 22. Do this…………
    Design an algorithm that will find the largest number in an array s
    s[1],s[2],…,s[n]
    Note: an array is a group of data of the same type
    Use while

×