11 Pages

lect17

Course: CSU 370, Fall 2009
School: Northeastern University
Rating:
 
 
 
 
 

Word Count: 2184

Document Preview

Design Object-Oriented CSU 370 Fall 2007 (Pucella) Lecture 17 Tuesday, Nov 13, 2007 Design Patterns A couple of lectures ago, we saw some design pattern to help us enforce statc properties, such as the Singleton pattern, or the Immutability pattern. Most design patterns, however, play the role of recipes for implementing a certain pattern of behaviors. Iterator Design Pattern We already saw one such pattern, the...

Register Now

Unformatted Document Excerpt

Coursehero

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Design Object-Oriented CSU 370 Fall 2007 (Pucella) Lecture 17 Tuesday, Nov 13, 2007 Design Patterns A couple of lectures ago, we saw some design pattern to help us enforce statc properties, such as the Singleton pattern, or the Immutability pattern. Most design patterns, however, play the role of recipes for implementing a certain pattern of behaviors. Iterator Design Pattern We already saw one such pattern, the Iterator design pattern, whose purpose is to implement the behavior provide sequential access to all the entries in an aggregate structure. The iterators we have studied were functional, via the following interface: public interface FunIterator<T> { public boolean hasNext (); public T next (); public FunIterator<T> advance (); } The fact that these iterators were functional is reected in the interface by having an explicit method to make the iterator advance to the next element. In particular, calling the next method repeatedly always returns the same answer. Putting it dierently, functional iterators are immutable. Java Iterators Now, you should all be aware that Java has a built-in notion of iterators, that the aggregator classes in the Java Collections Framework all implement. These iterators are similar in spirit to the functional iterators, and therefore are an instance of the Iterator design pattern, but they are mutable. Here is the interface Java implements: public interface Iterator<T> { public boolean hasNext (); public T next (); } 1 There is no explicit advance method. Instead, whenever the next method is invoked, it not only returns the next object in the iteration, it also automatically advances the iterator to the next object. Thus, invoking next twices on the same iterator may yield two dierent values. Part of the advantage of Java iterators is that Java oers syntactic support for them. Consider how you would use a Java iterator, for instance to iterate over all the elements of a LinkedList<Integer>? LinkedList<Integer> lst = ... // some code to create a list Iterator<Integer> it = lst.iterator(); while (it.hasNext()) { Integer nxt = it.next(); // some code acting on each integer in the list, e.g.: System.out.println ("Entry = " + nxt.toString()); } or, equivalently, using a for-loop: LinkedList<Integer> lst = ... // some code to create a list for (Iterator<Integer> it = lst.iterator(); it.hasNext(); ) { Integer nxt = it.next(); // some code acting on each integer in the list, e.g.: System.out.println ("Entry = " + nxt.toString()); } (Note that the for-loop does not have any update statementthe update is done implicitly in the call to next.) A class implements Iterable<T> if it has a method iterator that can return an iterator for the class. Class LinkedList<T>, for instance, implements Iterable<T>. When you have a class implementing Iterable<T>, we can use a special form of a for-loop, called a for-each-loop, as follows: LinkedList<Integer> lst = ... // some code to create a list for (Integer item : lst) System.out.println ("Entry = " + item.toString()); This is exactly equivalent to the for-loop above. You can think of the Java statement 2 for (TYPE ITEM_VAR : COLL_EXP) STATEMENT as shorthand for the longer for (Iterator<TYPE> it = COLL_EXP.iterator(); it.hasNext(); ) { TYPE ITEM_VAR = it.next(); STATEMENT; } Adapter Design Pattern Having two kinds of iterators around can lead to problem. For instance, you might care about using a library that implements a functional iterator, while your code has utility procedures that use Java iterators, or vice versa. It is of course possible to rewrite code, or reimplement the libraries to use the kind of iterators you code is expecting. Another possibility is to write a little class that adapts the objects returned by the library to interact better with your application. This is a general enough occurrence that we often call this an Adapted design pattern, although it is so obvious that the term seems like overkill. So lets write an adaptor class that wraps around a functional iterator and produces a Java iterator. First, lets dene a wrapper class that wraps a Java iterator around a functional iterator: public class IteratorWrapper<T> implements Iterator<T> { private FunIterator<T> iter; public IteratorWrapper (FunIterator<T> funIterator) { iter = funIterator; } public boolean hasNext () { return iter.hasNext(); } public T next () { T result = iter.hasNext(); iter = iter.advance(); return result; } } 3 Note the implementation of next, which needs to update the eld holding the functional iterator so that on the next call to next another object is extracted from the iteration. You should understand the above code, perhaps using the framework we described in the last lectures about how to model mutability. To use this adapter class, we only need to create an instance of it passing in a functional iterator. Consider the stack examples we have developed in the course, for which we supplied many dierent functional iterators available through a getFunIterator method. If st is an integer stack that has been constructed, then the following code gives us a Java iterator on a stack: Iterator<Integer> it = new IteratorWrapper(st.getFunIterator()); If additionally we want to be able to use the Java syntax above, we could dene an adapter class that wraps around the iterator wrapper and implements the Iterable interface, like so: public class IteratorAdapter<T> implements Iterable<T> { private FunIterator<T> iter; public IteratorAdapter (FunIterator<T> funIterator) { this.iter = funIterator; } public Iterator<T> iterator () { return new IteratorWrapper (iter); } } (Interesting question: why did I decide to store the functional iterator in the eld iter, as opposed to create the Java iterator once and for all at the time when IteratorAdapter is invoked and wrapping a new IteratorWrapper every time iterator is invoked? If you get this, you have nothing more to learn about mutation.) With the above adapter class, we can now use Java syntax to happily iterate over stacks: Stack st = ... // some code to create an integer stack for (Integer item : new IteratorAdapter(st.getFunIterator())) System.out.println ("Entry = " + item.toString()); Exercise: can you write a wrapper class that turns a Java iterator into a functional iterator? 4 Visitor Design Pattern Iterators are a great way to traverse an aggregate structure, that is, a structure which is just a collection of other objects. A related problem is one of traversing a structured object. What do I mean by a structured object? It is an object made up of sub-objects, themselves possibly made of up of sub-objects as well, and so on. The classical example of this in the literature is a car object. Suppose we wanted to implement a class representing a car. This could be useful, for instance, in application an designed to help engineers design new cars. Lets keep thing simple for now, but you can imagine a car as being made up of a number of parts, for instance, four wheels, a chassis, an engine, a steering column, seats. Each wheel is made up of a tire and an axle connector. The seats are made of of stung and covering fabric. And so on. As you see, a single car is structured, and each element of the structure can be represented as its own structured object. The problem: how do you traverse such a structured object, for instance, to perform an operation such as printing data at every element of the structure? We will call the design we derive a Visitor design pattern, because it will give us a way to visit every element of a structured object and do something interesting at every node. And the above sentence gives a hint as to how we will approach things. We will decouple: (1) the act of traversing the structured object, and (2) the action to perform at every element. To traverse the structured object, we will implement, in every class that can be part of the structure of the object, a method accept that will be in charge of traversing that part of the structure, possibly invoking accept on sub-objects of the structure. Lets look at how this is done for the Rect example of a couple of lectures ago. The example is near trivial, but it illustrates the concept. public class Interval { private int lower; private int higher; ... public void accept (...) { } } 5 public class Rect { private Interval width; private Interval height; ... public void accept (...) { this.width.accept(...); this.height.accept(...); } } Lets not worry about what we pass to accept for now. Just pay attention to the structure. When traversing a Rect, we simply in turn traverse both Intervals in it. This takes care of the traversal part. Now we would like to describe what to do at each step of the traversal. To do so, we are going to pass a structure to accept that will describe what to do at every element of the structure. That structure will be an instance of the following ShapeVisitor interface: public interface ShapeVisitor { public void visit (Interval obj); public void visit (Rect obj); } A ShapeVisitor gives functions (one per class that we can traverse) that describe what to do at any point of the traversal. We can now update the traversal code to carry such a visitor object around, and invoke it at the appropriate points. public class Interval { private int lower; private int higher; ... public void accept (ShapeVisitor visitor) { visitor.visit(this); } } 6 public class Rect { private Interval width; private Interval height; ... public void accept (ShapeVisitor visitor) { visitor.visit(this); this.width.accept(visitor); this.height.accept(visitor); } } Note that at every element we traverse, we invoke the visitors visit method on the current element. (The types will ensure that Java will resolve the overloading and invoke the right method.) As an example, consider the following (again, near trivial) visitor for shapes: public class PrintShapeVisitor implements ShapeVisitor { public PrintShapeVisitor () { } public void visit (Interval obj) { System.out.println (" Visiting interval [" + obj.getLower() + " , " + obj.getHigher() + "]"); } public void visit (Rect obj) { System.out.println ("Visiting rectangle"); } } We can now traverse a rect object of type Rect by invoking: rect.accept (new PrintShapeVisitor()); which produces output like: Visiting rectangle 7 Visiting interval [0,10] Visiting interval [0,20] Lets look at a less trivial example. Recall the integer binary trees I asked you to implement on the midterm, with the following signature and algebraic specication. public public public public public public static Tree empty (); static Tree node (int, boolean isEmpty (); int root (); Tree left (); Tree right (); Tree, Tree); // extract value at root node // extract left subtree of node // extract right subtree of node Tree.empty().isEmpty() = true Tree.node(v,l,r).isEmpty() = false Tree.node(v,l,r).root() = v Tree.node(v,l,r).left() = l Tree.node(v,l,r).right() = r Lets implement a visitor for ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 15 Tuesday, Nov 6, 2007On Enforcing Static PropertiesLast time, we saw the main property that the Java type system enforces, namely if a program type checks, then at no point during the executio
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 16 Friday, Nov 9, 2007A Model of Mutation in JavaWe have been avoiding mutations until now; but there are there, in the Java system, for better or for worse, especially in the libraries. So let'
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 14 Friday, Nov 2, 2007(These notes are very rough, and differ somewhat from what I presented in class; I am posting them here to supplemental your own notes.)1Type Checking JavaBefore the midt
Northeastern University - CSU - 370
- baby Java- ADT specification (signature, algebraic specification)- algebraic reasoning- implementation in Java- static vars / methods- interface &amp; substitutability- black box testing- type system / subclassing- canonical methods- implicit spec
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 13 Tuesday, Oct 23, 2007Generics in GeneralLast class, we introduced generic interfaces, that is, interfaces that are parameterized by a type. Today, let's try to generalize this to parametrizin
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 12 Friday, Oct 19, 2007Functional Iterators, ContinuedLast time, we started looking at functional iterators. I nished with a couple of questions. Lets answer them. First, lets see how to use suc
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 11 Tuesday, Oct 16, 2007The Comparable InterfaceThere are two main ways, in practice, in which interfaces are used in Java programming: (1) To capture functionality orthogonal to the natural cla
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 9 Friday, Oct 5, 2007Inheritance SubtletiesLast time, we saw inheritance as a way to re-use code in a subclass. Ther are some general rules for what is accessible from an inheriting subclass, an
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 10 Friday, Oct 12, 2007Nested ClassesLast time, we saw a recipe for deriving an implementation from an ADT specication. There are two problems with that approach, however, one minor, one major:
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 8 Tuesday, Oct 2, 2007Subclassing and InheritanceA Detour: Mutability versus ImmutabilityBefore starting this lecture, let me say something about an important point in class design. All of the
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 6 Tuesday, Sep 25, 2007Static and Dynamic ErrorsConsider the kind of errors that can occur in programs. Let me abstract from Java for the moment, and speak in general. There are various errors p
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 5 Friday, Sep 21, 2007The Java Type System (continued)The Object Class All classes subclass the Object class. (By default, this is the superclass used when you do not specify an extends class in
Northeastern University - CSU - 370
Object-Oriented Design CSU 370 Fall 2007 (Pucella)Lecture 4 Tuesday, Sep 18, 2007The Java Type SystemBy now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language, because this will become important as we stud
SUNY Oswego - CSC - 344
cfw_- file: nim.hs game of nim-module Main whereimport Data.Char (chr, ord)import System.Environment (getArgs)import System.IOtakeaway(a,b) = if a &lt; b then 0 else a - b;string_to_int: String -&gt; Intstring_to_int s = let do_string_to_int n []
SUNY Oswego - CSC - 344
Script started on XXX &gt; diff Rat2.hs Rat3.hs2c2&lt; module Rat2 where-&gt; module Rat3 where14c14&lt; let g = Rat2.gcd(a, b)-&gt; let g = Rat3.gcd(a, b)19a20&gt; deriving (Read)24a26,28&gt; (+) : Ratio -&gt; Ratio -&gt; Ratio&gt; (+) x y = addrat(x,y)&gt; 32c36&lt; Ratio
SUNY Oswego - CSC - 344
module Rat1 wheregcd(a, b) = let do_gcd(x, y) = if y = 0 then x else do_gcd(y, x `mod` y) in if a &gt;= b then do_gcd(a, b) else do_gcd(b, a) reduce(n, d) = let a = abs(n) b = abs(d) in let g = Rat1.gcd(a, b) in ( (if (n &lt; 0) = (d &lt; 0) then a
SUNY Oswego - CSC - 344
/ file: Laughin2.javapublic class Laughin2cfw_ static Cerberus cerberus = new Cerberus(); static Thread straight; static Thread gag; static class Cerberus cfw_ synchronized void straightline() cfw_ while (turn != 0 &amp; !done) cfw_ try cfw_ wait(1
SUNY Oswego - CSC - 344
/ file: Laughin1.javapublic class Laughin1cfw_ static Cerberus cerberus = new Cerberus(); static class Cerberus cfw_ synchronized void straightline() cfw_ while (turn != 0) cfw_ try cfw_ wait(1000); catch (InterruptedException ie) cfw_ which
SUNY Oswego - CSC - 344
class Semaphorecfw_ public Semaphore() cfw_ this(1); public Semaphore(int i) cfw_ value = i; public synchronized void P() cfw_ while (value &lt;= 0) cfw_ try cfw_ wait(); catch (InterruptedException e) cfw_ value-; public synchronized void V
SUNY Oswego - CSC - 344
class Semaphorecfw_ public Semaphore() cfw_ this(1); public Semaphore(int i) cfw_ value = i; public synchronized void P() cfw_ while (value &lt;= 0) cfw_ try cfw_ wait(); catch (InterruptedException e) cfw_ value-; public synchronized void V
SUNY Oswego - CSC - 344
enum Phase cfw_ODD, EVENpublic class Taska implements Runnablecfw_ Phase phase; int count; public Taska(Phase phase, int count) cfw_ this.phase = phase; this.count = count; public void run() cfw_ switch (phase) cfw_ case ODD: for (int i =
Washington University in St. Louis - CSE - 577
CS 577 Design and Analysis of Switching SystemsExam 2 SolutionsJonathan Turner 11/23/041. (10 points) Consider a switching system which uses a crossbar with virtual output queues and a LOOFA scheduler. Suppose that this system implements multicast by h
North-West Uni. - REB - 991
To appear in Language and Speech. Please do not quote or cite without permission from the authors.Variability in Word Duration as a Function of Probability, Speech Style, and Prosody Rachel E. Baker Northwestern University Evanston, IL Ann R. Bradlow Nor
North-West Uni. - REB - 991
Is Articulation Level Controlled by Prosodic Prominence?Rachel Baker and Ann BradlowNorthwestern University r-baker2@northwestern.edu MCWOP PresentationArticulation LevelHypo-articulationshorter durations smaller vowel spaceHyper-articulationlonger
North-West Uni. - CEN - 342
Caroline EngstlerDepartment of Linguistics, Northwestern University 2016 Sheridan Road Evanston, IL 60208-4090 c-engstler@northwestern.eduEducation 2005-present Ph.D. program, Department of Linguistics, Northwestern University, Evanston, Illinois Specia
North-West Uni. - REB - 991
Addressing Challenges Posed by Speech Corpora Including Non-Native SpeakersRachel E. Baker, Chun-Liang Chan, Kristin Van Engen and Ann R. BradlowDepartment of Linguistics, Northwestern University1. IntroductionCorpora of recorded speech are vital reso
North-West Uni. - CEN - 342
Lexical properties modulate phonological attrition: Evidence from GermanCaroline Engstler &amp; Matt Goldrick Department of Linguistics Northwestern UniversityMCWOP 20071Talk outlineIs cross-language transfer lexically conditioned? - Cross-language trans
North-West Uni. - REB - 991
Reactive Redundancy and Listener Comprehension in Direction-GivingRachel E. BakerDepartment of Linguistics Northwestern University Evanston, IL 60208 r-baker2@northwestern.eduAlastair J. Gill, Justine CassellCenter for Technology and Social Behavior N
SUNY Oswego - CSC - 344
- Exceptions -E.g., - 4 div 3;val it = 1 : int - 4 div 0;uncaught exception Div - 4 div 0 handle Div =&gt; 0;val it = 0 : intReturning to tree operations:Using the tree operations (putting a dictionary intoa binary search tree):use &quot;tree.m&quot;;use
North-West Uni. - MAW - 962
NOT FOR SALEThe Meaning of Names in HadramautMary Ann Walter Massachusetts Institute of TechnologyPersonal names in Wadi Hadramaut1 differ in several interesting ways from names used elsewhere in the Arab world. For obvious sociohistorical reasons, mos
North-West Uni. - MAW - 962
Consonant Confusability: An MEG StudyVALENTINE HACQUARD &amp; MARY ANN WALTER Massachusetts Institute of Technology0. Introduction Numerous behavioral experiments have investigated consonant confusability by evaluating error rates in identification of phone
SHSU - MATH - 143
Math 143 Spring, 2003 Exam 1 Chapters 4, 5, and 6 Part I - Denitions and Examples 1. (5 points) State the denition of an integrable function. Solution: A function f (x) is integrable on [a, b] if a f (x)dx exists, i.e. for any partition p of [a, b] let th
University of Rochester - PHYS - 107
Lecture 1 February 12, 2002Today: Thursday: Lab: 1 The Nature ofSound 1st 1 The Nature of Sound 2nd Lab 1: Problem Solving &amp; Oscilloscope HW1: 0Materials Pasco Function Generator Oscilloscope Pasco oscillator Speaker Base guitar string &amp; masses &amp; board
SUNY Oswego - CSC - 344
#include &lt;iostream&gt;#include &lt;string&gt;using namespace std;#include &quot;heap.h&quot;struct Datum cfw_ friend ostream&amp; operator&lt;(ostream&amp; os, Datum d) cfw_ return cout &lt; d.val; int val; Datum(void) : val(0) cfw_ Datum(int v) : val(v) cfw_ Datum(const Datum
Alaska Anch - CS - 351
Sample Midterm Exam CS351 100 Points TotalName: _Please write neatly and show your work. The exam is open book, open notes, and you may use any computing devices. You have one hour and 15 minutes. Good luck! 1. Short Answer (12 pts). Provide brief 1-3 s
Seton Hall - CSAS - 3211
CSAS 3211 Practice1. What do the following terms mean: a. IP number: A unique identifier for computer on the internet. Consists of 4 numbers, each between 0 and 255 b. DHCP: An &quot;IP number&quot; server that assigns dynamically IP numbers to hosts on a LAN c. D
Duke - CPS - 100
Test 2 Practice: CPS 100Owen Astrachan November 5, 2004Name: Login: Honor code acknowledgment (signature)Problem 1 Problem 2 Problem 3 Problem 4 TOTAL:value 20 pts. 30 pts. 20 pts. 20 pts. 90 pts.gradeThis test has 14 pages, be sure your test has th
Duke - CPS - 006
What does this position entail?Do you want to build quantitative models millions of people will use, based on data from the world's largest online laboratory? Are you passionate about formulating relevant questions and producing solutions to initially il
Duke - CPS - 006
Recursion and Recursive StructuresDefinition in the dictionary: in mathematics an expression in which a value is calculated by using preceding terms of the expression Pretty worthless, doesnt convey details or power Consider folders and files in a comput
Duke - CPS - 006
What is an IStrand?Why are IStrand objects used instead of Strings? Strings don't have names Strings restrict us to specific methods, or we have to write methods and pass strings to them IStrand objects allow the methods to be in the class, this is part
Duke - CPS - 006
Genome Revolution: COMPSCI 006G14.1From practice to theory and back againIn theory there is no difference between theory and practice, but not in practice How do we search an array or an ArrayList for a value? I'm thinking of a number from 1 to 100 Wh
Duke - CPS - 006
What is Information? http:/dictionary.com1. 2. 3. 4.5. 6. 7.Knowledge derived from study, experience, or instruction. Knowledge of specific events or situations that has been gathered or received by communication; intelligence or news. A collection of
Duke - CPS - 006
Interfaces: improving ShotgunWe don't want to use a String to represent a DNA strand/sequence Probably not efficient for merging two strands Strands can't have annotations: names, features,. Doesn't mirror what's done in BioJava library We want to use a
Duke - CPS - 006
From Interfaces to IteratorsWe want to look at all the elements in an ArrayList We want to look at all the genomic sequences in a FASTA file We want to read all the words in a file We want to read all the lines in a file We want to iterate over a collect
Duke - CPS - 006
What is the Object Concept?Ask not what you can do to an object, ask what an object can do to itself Object has internal state, data Operations on the object affect the internal state Can expose state to client programs Can change state in some waysAn
Duke - CPS - 006
Refactoring, what, when,how?Programs are hard to get right the first time Similar to an essay paper? Rewrite? Code isn't fast enough, but it works Code isn't general enough, but it solves the problem Code passes initial tests, then becomes problematic R
Duke - CPS - 006
FOCUS COMPSCI 006G Genome RevolutionOwen Astrachan http:/www.cs.duke.edu/courses/cps006g/fall04 http:/www.cs.duke.edu/~olaGenome Revolution: COMPSCI 006G1.1Where are we going?What is computer science? What is biology? What is computational biology? W
Duke - CPS - 006
How to design/write programsStart with a small, working program Don't write 10's, 100's, 1000's of lines before compiling Compile, test, implement, repeat Add features to an already working program A program designed to do nothing is a known entity No re
Duke - CPS - 130
Meeting 26December 1, 2004Approximation Algorithms(read Section 35 on Approximation Algorithms in C ORMEN , L EISERSON , R IVEST, S TEIN)98 UQT q8eddD( q 55 63 4(1 Vertex Cover. The rst problem we consider is nding the minimum set of vertices in
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Helvetica Times-Bold Times-Italic Courier %EndComments %DVIPSWebPage: (www.radi
Duke - CPS - 130
Meeting 25November 29, 2004NP-Complete Problems(read Section 34 on NP-Completeness in C ORMEN , L EISERSON , R IVEST, S TEIN)Step 2. Convert each clause into disjunctive normal form. The most mechanical way uses the truth table for each clause, as ill
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Helvetica Times-Bold Times-Italic Courier %EndComments %DVIPSWebPage: (www.radi
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Helvetica Times-Bold Times-Italic %EndComments %DVIPSWebPage: (www.radicaleye.c
Duke - CPS - 130
Meeting 24November 22, 2004Easy and Hard Problems(read Section 34 on NP-Completeness in C ORMEN , L EISERSON , R IVEST, S TEIN)P92 B5 1 i`@47dX h$#8g7 X `V7A2X 7 B5 1 B 5 1 8 fe@47dX cb7 #Ua`YX B5 1 W2VA7 7 R $#UTSQAs an example consider the shorte
Duke - CPS - 130
Meeting 23November 17, 2004Pattern MatchingThis material is not covered in our textbook but you can read about pattern matching in Chapter I.3 of Algorithms on Strings, Trees, and Sequences by G USFIELD.the sequence starts with a non-empty sequence of
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Bold Courier Times-Italic %EndComments %DVIPSWebPage: (www.radicaleye.com
Duke - CPS - 130
Meeting 23November 15, 2004Searching with StringsThis material is not covered in our textbook but you can read about keyword trees and sufx trees in Chapters I and II of Algorithms on Strings, Trees, and Sequences by G USFIELD.o1p1t a2 3 1 1 2t
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Bold Courier Times-Italic %EndComments %DVIPSWebPage: (www.radicaleye.com
Duke - CPS - 130
Meeting 21November 10, 2004String Matching(read Section 32 on String Matching in C ORMEN , L EISERSON , R IVEST, S TEIN)HOCUSPOCUSABRA BRACADABRA. ABRA ABR AB A CADABRA ACADABRA RACADABRA BRACADABRAThe straightforward approach to solving this problem
Duke - CPS - 130
Meeting 20November 8, 2004Union-Find(read Section 21 on Data Structures for Disjoint Sets in C ORMEN , L EISERSON , R IVEST, S TEIN)This section presents two data structures for the disjoint set system problem we encountered in the implementation of K
Duke - CPS - 130
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: Book.dvi %Pages: 3 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: Times-Roman Times-Italic Times-Bold Courier %EndComments %DVIPSWebPage: (www.radicaleye.com