Algorithms - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Algorithms

Description:

Bubble sort (n lg n) running time sorting. Quick sort. Merge sort. Heap sort ... TEXT Strings strings on alphabet of letters, numbers, and spec chars. ... – PowerPoint PPT presentation

Number of Views:88
Avg rating:3.0/5.0
Slides: 20
Provided by: irena
Category:

less

Transcript and Presenter's Notes

Title: Algorithms


1
Algorithms
  • Irena Pevac
  • CCSU

2
Design Techniques
  • A design technique or strategy is general
    approach to solving problems algorithmically that
    is applicable to a variety of problems from
    different aras
  • Brute force
  • Divide and conquer
  • Dynamic
  • Greedy

3
Methods to specify an Algorithm
  • Pseudocode
  • Mixture of natural language and programming
    language
  • Flowchart
  • Method of expressing an algorithm by a collection
    of connected geometric shapes containing
    descriptions of the algorithms steps.

4
Analyzing an Algorithm
  • Time efficiency
  • Space efficiency
  • Simplicity
  • Generality

5
Proving Correctness
  • Prove that the algorithm produces required result
    for every single input in finite amount of time.
  • Mathematical induction is often used to prove
    that certain assertion holds for every integer.

6
Problem Types
  • Sorting
  • Searching
  • String processing
  • Graph problems
  • Combinatorial problems
  • Geometric problems
  • Numerical problems

7
Sorting
  • Quadratic ?(n2) running time sorting
  • Insertion sort
  • Selection sort
  • Bubble sort
  • ?(n lg n) running time sorting
  • Quick sort
  • Merge sort
  • Heap sort

8
Stable Sorting Algorithms
  • Sorting algorithm is stable if it preserves the
    relative order of any two equal elements in the
    input
  • Important in case when we sort students by gpa
    that were sorted alphabetically. All students
    with same gpa stay sorted.
  • Another example sort students by departments
    (major or minor)

9
In Place Algorithm
  • An algorithm is called in place if it does not
    require more that some constant number of extra
    spaces in memory.
  • If the extra amount of space is proportional to
    the size of input it is not stable.

10
Searching
  • Find a given value called search key in a given
    list, set or multiset
  • In multiset several items have the same value.

11
Sequential search
  • Check one by one item in the given collection of
    items.
  • For each item check if it equals to the key that
    we are searching for.
  • If the key is found stop further search.
  • If the end of collection is reached without
    finding the key the search is stopped without
    success.

12
Binary Search
  • Algorithm applicable to sorted list only.
  • Check if item in the middle equals to the key.
  • If not if key is smaller than item in the middle
    proceed with search in the sublist left of the
    item in the middle.
  • if key is larger than item in the middle proceed
    with search in the sublist right of the item in
    the middle.
  • Stop if key is found (successful search) or if
    sublist is empty (unsuccessful search).

13
String Processing
  • String is a sequence of characters from some
    given alphabet.
  • TEXT Strings strings on alphabet of letters,
    numbers, and spec chars.
  • BIT strings strings on 0,1
  • GENE SEQUENCES strings on the alphabet
    A,C,G,T

14
String Matching
  • INPUT Given text and given pattern
  • String matching algorithm has to find the
    location of the pattern in the text.
  • Variations
  • First occurrence
  • N-th occurrence
  • All occurrences

15
Graph Problems
  • Set of vertices (nodes) some of which are
    connected by edges.
  • Directed
  • Undirected
  • Labeled edges (weighted)

16
Graph algorithms
  • Graph traversal
  • Shortest path
  • Topological sorting
  • Traveling salesman
  • Graph coloring- event scheduling

17
Combinatorial Problems
  • Find a combinatorial object
  • Find all permutations
  • Find all combinations n-choose-m
  • Find all subsets of a given set
  • Find a combinatorial object with desired property
    ( to maximize or minimize cost)

18
Geometric Problems
  • Greeks
  • Construct a triangle with unmarked ruler and a
    compass
  • Closest pair
  • Find the closest pair of n points in a plane.
  • Convex hull problem
  • Find the smallest convex polygon that contains
    all n points in the plane

19
Numerical Algorithms
  • Solving system of equations
  • Computing definite integrals
  • Evaluate functions
  • Most algorithms are approximate
  • Round off error
  • Error may accumulate if large number of
    operations is performed on approximate numbers.
Write a Comment
User Comments (0)
About PowerShow.com