Transform - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Transform

Description:

Example: Given a random list of numbers, determine if there are any duplicates. Brute Force: Compare Every Pair. Transform and Conquer: Sort the List ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 19
Provided by: Saa93
Category:
Tags: brute | transform

less

Transcript and Presenter's Notes

Title: Transform


1
Transform Conquer
  • Replacing One Problem With Another

Saadiq Moolla
2
Introduction
Initial Problem
  • Two Stage Solution
  • Transform into Another Problem
  • Solve New Problem
  • Three Variations
  • Instance Simplification
  • Representation Change
  • Problem Reduction

New Representation
Solution
3
Instance Simplification
  • Reducing the Problem to a Simpler One
  • Techniques
  • Presorting
  • Gaussian Elimination
  • Search Trees

4
Presorting
  • Example Given a random list of numbers,
    determine if there are any duplicates.
  • Brute Force Compare Every Pair
  • Transform and Conquer
  • Sort the List
  • Compare A i with A i 1 i

A
5
Presorting (Analysis)
  • Old Idea, Many Different Ways
  • Efficiency Dependant on Algorithm
  • Compare Benefits vs Time Required
  • Useful if Operation Repeated

6
Gaussian Elimination
7
Binary Search Trees
8
4
15
7
9
1
5
8
Binary Search Trees (Analysis)
  • Time Efficiency
  • Slow
  • Methods to Balance
  • Special Trees
  • AVL Trees
  • B-trees

9
Heaps
9
  • Type of Binary Tree
  • Requirements
  • Essentially Complete
  • Parental Dominance

5
7
4
2
1
10
Properties of Heaps
  • Height is log2n
  • Root is largest element
  • Node Descendents Heap
  • Stored in Array
  • Children of A i are A 2i and A 2i 1

11
Heap Insertion
9
5
8
7
4
2
1
12
Heaps (Analysis)
  • Sorting
  • Priority Queue
  • O (n log n)

13
Representation Change
  • Change One Problem Into Another
  • Steps
  • Identify
  • Transform
  • Solve
  • Mathematical Modeling

14
Problem Reduction
  • Reduce to a Known Problem
  • Use Known Algorithms
  • Dijkstras algorithm
  • Horners Rule
  • Karp Rabin algorithm
  • etc.

15
Horners Rule
  • Used to Evaluate Polynomials
  • 5x2 3x 8 (5x 3)x 8
  • 7x3 x2 9x 2 ((7x 1)x 9)x 2
  • Linear

16
Horners Algorithm
algorithm Horner (x, P ) // Evaluates a
polynomial with coefficients P at x for i ? n
1 downto 0 do v ? x v P i return v
17
Fast Exponentiation
  • Evaluate xn
  • 210 210102 28 22

18
Fast Exponentiation Algorithm
Algorithm FastExp (x, n) // Returns xn term ?
x product ? 1 while n gt 0 do if n mod 2 1
then product ? product term term ? term
term n ? n/2 return product
Write a Comment
User Comments (0)
About PowerShow.com