CSCOE 1501 Recitation 3 Dynamic Programming: Edit Distance Problemhw1 - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

CSCOE 1501 Recitation 3 Dynamic Programming: Edit Distance Problemhw1

Description:

Spell checker finding the closest match of a misspelled word. Edit Distance Problem: for 2 strings, finding the length of their shortest alignment ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 7
Provided by: zhangz
Category:

less

Transcript and Presenter's Notes

Title: CSCOE 1501 Recitation 3 Dynamic Programming: Edit Distance Problemhw1


1
CS/COE 1501 Recitation 3Dynamic Programming
Edit Distance Problem(hw1)
  • Zhoulan Zhang
  • http//www.cs.pitt.edu/zzl

2
Problem Definition
  • Spell checker finding the closest match of a
    misspelled word
  • Edit Distance Problem for 2 strings, finding the
    length of their shortest alignment
  • ( of mismatched columns).
  • abc acde
  • shoes socks

3
Dynamic Programming
  • Recall the Knapsack Problem
  • Construct a matrix of size j i
  • ( of items capacity limit M)
  • Bottom- up
  • How about this Edit Distance Problem?

4
Base Case
  • When either s1 or s2 is null
  • s1 is null distance(s1,s2) s2.length()
  • s2 is null distance(s1,s2) s1.length()
  • We can fill the first row and first column of our
    matrix

5
Recursive Case
  • s11...i s21...j.
  • 3 possibilities for the last column
  • ... s1i - ... s1i
  • ... - ... s2j ... s2j

6
Wrap Up
  • Constructs a matrix of edit distance for all
    prefixes of 2 strings
  • Fill out 1st row and 1st column
  • Fill out the other slots according to the
    recursive definition
Write a Comment
User Comments (0)
About PowerShow.com